Add a custom right-click menu using jQuery

Developer
Size
2,476 Kb
Views
32,384

How do I make an add a custom right-click menu using jquery?

Inspired by something on Stack Overflow, this will allow you to have a custom right-click menu in certain areas of your application. For Example: Right clicking in the table will display the custom menu, as right-clicking off the table will display the browser's default menu.. What is a add a custom right-click menu using jquery? How do you make a add a custom right-click menu using jquery? This script and codes were developed by Ty Stelmach on 09 December 2022, Friday.

Add a custom right-click menu using jQuery Previews

Add a custom right-click menu using jQuery - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Add a custom right-click menu using jQuery</title> <script src="https://code.jquery.com/jquery.min.js"></script> <link href="https://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" /> <script src="https://getbootstrap.com/dist/js/bootstrap.js"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrap">
<div> <h1>Custom Right-Click Interface Menus</h1>
</div>
<table id="mt" class="table"> <thead> <tr> <th>#</th> <th>First Name</th> <th>Last Name</th> <th>Username</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Ty</td> <td>Stelmach</td> <td>@TyStelmach</td> </tr> <tr> <td>2</td> <td>Andy</td> <td>Hawkins</td> <td>@ahawkins</td> </tr> <tr> <td>3</td> <td>Lawrence</td> <td>Bird</td> <td>@LarryBird</td> </tr> <tr> <td>4</td> <td>Sally</td> <td>Saran</td> <td>@SalPal</td> </tr> <tr> <td>5</td> <td>Heather</td> <td>Long</td> <td>@HeatherLong</td> </tr> </tbody> </table> <div id="contextMenu" class="dropdown clearfix"> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;"> <li><a tabindex="-1" href="#">Action 1</a> </li> <li><a tabindex="-1" href="#">Action 2</a> </li> <li><a tabindex="-1" href="#">Some More Actions</a> </li> <li class="divider"></li> <li><a tabindex="-1" href="#">Final Action</a> </li> </ul> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Add a custom right-click menu using jQuery - Script Codes CSS Codes

#contextMenu { position: absolute; display: none;
}
.wrap{ width:90%; display:block; margin:0 auto;
}
table{border:1px solid rgba(221, 221, 221, 1);}
tr:nth-child(even) {background: #F5F5F5}
tr{ position:relative;
}
tr:hover{ background:#c9e8f7; position:relative;
}

Add a custom right-click menu using jQuery - Script Codes JS Codes

$(function() { var $contextMenu = $("#contextMenu"); $("body").on("contextmenu", "table tr", function(e) { $contextMenu.css({ display: "block", left: e.pageX, top: e.pageY }); return false; }); $('html').click(function() { $contextMenu.hide(); });
});
Add a custom right-click menu using jQuery - Script Codes
Add a custom right-click menu using jQuery - Script Codes
Home Page Home
Developer Ty Stelmach
Username TyStelmach
Uploaded December 09, 2022
Rating 3
Size 2,476 Kb
Views 32,384
Do you need developer help for Add a custom right-click menu using jQuery?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ty Stelmach (TyStelmach) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!