How to add dbclick() on right click in jQuery? Last Updated : 01 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The jQuery dblclick() method is used to detect whenever a particular element is double-clicked. This method only detects left mouse button double clicks and not the right mouse button double clicks. In this article, we will see how to simulate the double right mouse click in jQuery. Approach: There are two HTML div elements, one with an id target and the other with an id result. Attach an event handler to the target id by using the on() method. The event name is contextmenu which simply suppresses the right-click menu as we want to prevent the default action of right-clicking using the preventDefault() method.The mouseup() method is attached to the target id element to detect the event when the user releases a mouse button over this element. An anonymous function with a parameter event is passed as a parameter to the mouseup() method such that we can utilize the which, originalEvent, and the detail properties of the event object.The which property is used to check which mouse button is clicked, left or right It returns 3 if it is a right-click, so we use this as a base condition.We use the originalEvent and the detail properties of the event object to check whether it is a single right-click or a double right-click. These properties return 2 if it is a double right-click else returns 1. The result id element displays this single or double right-click using the text() method. Example 1: In this example, we are using the above-explained approach. HTML <!DOCTYPE html> <html> <head> <!-- jQuery --> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script> <!-- Basic inline styling --> <style> body { text-align: center; } h1 { color: green; font-size: 2.5rem; } div { font-weight: bold; font-size: 1.5rem; } #target { cursor: pointer; margin-bottom: 2rem; } #result { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <div id="target">Right click here to see effect</div> <div id="result"></div> <script type="text/javascript"> // Suppress the right-click menu $("#target").on("contextmenu", function (event) { event.preventDefault(); }); $("#target").mouseup(function (event) { if (event.which === 3) { if (event.originalEvent.detail === 2) { $("#result").text("Double right-click!"); } else if (event.originalEvent.detail === 1) { $("#result").text("Single right-click!"); } } }); </script> </body> </html> Output: Example 2: In this example, we are only checking for a double right-click instead of both a single and a double right-click. It means only the condition event.originalEvent.detail === 2 is checked. Moreover, we append the text every time on double right click instead of simply displaying it once so that we can see exactly how many doubles right-click have been performed. We have performed the double right-click operation exactly 5 times. HTML <!DOCTYPE html> <html> <head> <!-- jQuery --> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script> <!-- Basic inline styling --> <style> body { text-align: center; } h1 { color: green; font-size: 2.5rem; } div { font-weight: bold; font-size: 1.5rem; } #target { cursor: pointer; margin-bottom: 2rem; } #result { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <div id="target">Right click here to see effect</div> <div id="result"></div> <script type="text/javascript"> // Suppress the right-click menu $("#target").on("contextmenu", function (event) { event.preventDefault(); }); $("#target").mouseup(function (event) { if (event.which === 3) { if (event.originalEvent.detail === 2) { $("#result").append("Double right-click!" + "<br />"); } } }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to add dbclick() on right click in jQuery? R rajatsandhu2001 Follow Improve Article Tags : Web Technologies JQuery Geeks Premier League Geeks-Premier-League-2022 CSS-Properties jQuery-Methods jQuery-Questions +2 More Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read 3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power 13 min read Like