How to Double click on a div element to toggle background color in jQuery ? Last Updated : 25 Mar, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to make a double click event on a paragraph element to toggle background color in jQuery. To toggle the background color of a div element on double-click, toggleClass() method is used. The toggleClass() method is used to toggle or change the class which attached with selected element. Syntax: $(selector).dblclick(function() { $(selector).toggleClass("element"); }) Example: HTML <!DOCTYPE html> <html> <head> <title> How to Double click on a paragraph to toggle background color in jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> $(document).ready(function () { var block = $(".main"); block.dblclick(function () { block.toggleClass("GFG"); }); }); </script> <style> body { text-align: center; } .main { width: 350px; height: 200px; border: 2px solid black; } .GFG { background: green; color: white; } </style> </head> <body> <div class="main"> <h1>GeeksforGeeks</h1> <h3> How to Double click on a paragraph to <br>toggle background color in jQuery? </h3> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to attach a click and double-click event to an element in jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery HTML-Tags CSS-Properties jQuery-Questions +1 More Similar Reads How to get the background color of a clicked division using jQuery ? In this article, we will learn how to get the background color of a clicked division using jQuery. Approach: All the divisions on the page are first selected using a common selector and a click binding is applied to trigger the color detection using the click() method. The division that is then curr 2 min read How to toggle background color using right click in jQuery ? In this article, we will learn to toggle the background color using the right-click in jQuery. Approach 1: The approach is by using the contextmenu event. The contextmenu() method is used to bind the contextmenu event to the element being used. This can be used to perform the color toggling action o 4 min read How to run a code on double-click event in jQuery ? In this article, we will see how to run a code after double clicked the element using jQuery. To run the code on double clicked we use dblclick() method. This method is used to trigger the double-click event to occur. This method occurs when the selected element will be double clicked. Syntax: $(sel 1 min read How to attach a click and double-click event to an element in jQuery ? In this article, we will see how to attach a click and double-click event to an element in jQuery. To attach click and double-click events, click and dbclick events are used. These events are attached with the bind() method. This method is used to attach one or more event handlers for selected eleme 1 min read How to set background color of a particular div in jQuery ? jQuery is one of the powerful libraries of JavaScript that contains many powerful methods for manipulating the DOM or selecting DOM elements and modifying the DOM elements. In this article, we will set the background color of 4th division to red by adding an appropriate class in jQuery. Approach: Th 3 min read How to change background color of paragraph on double click using jQuery ? In this article, we will see how to change the background color of a paragraph using jQuery. To change the background color, we use on() method. The on() method is used to listen the event on an element. Here we are going to use dblclick event. For changing the background color we are going to use c 2 min read Like