BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

jQuery dblclick() Method

Last Updated: April 28, 2019 by Chaitanya Singh | Filed Under: jQuery

jQuery dblclick() Method attaches a double click event handler function to an html element. This event handler function executes when a user double clicks on the attached html element.

jQuery dblclick() Method Syntax

$(selector).dblclick(function(){
    //event handler code. This code will execute
    // when a user double clicks on the selected html element.
});

Here $(selector) is a jQuery selector that selects an html element and the dbclick() method attaches that selected element to the event handler function.

jQuery dblclick() Example

In the following example we have attached the double click event handler function to the jQuery selector that selects h2, p and button elements, which means whenever a user double clicks on any of these elements, they will be hidden because in event handler function we are calling hide() method like this: $(this).hide(); that hides the current element.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("h2, p, button").dblclick(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>

<h2>jQuery double click event example</h2>
<p>This example is published on beginnersbook.com. When you double
click on the heading, paragraph or button, they will be hidden</p>
<button>Button</button>
</body>
</html>

Output:
Before a user double clicks on any html element:
jQuery dblclick
After a user double clicks on the h2 heading:
jQuery dblclick() method
After a user double clicks on the paragraph:
jQuery dblclick event example
After a user double clicks on the button:
Blank page with no elements.

❮ PreviousNext ❯

Top Related Articles:

  1. jQuery html() method
  2. jQuery Sliding Effects
  3. jQuery Multiple Elements Selector
  4. jQuery Events
  5. jQuery removeClass() Method

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

jQuery Tutorial

  • jQuery Tutorial
  • jQuery Selectors
  • jQuery Events

jQuery Effects

  • jQuery Show & Hide
  • jQuery Fading
  • jQuery Sliding
  • jQuery Animate
  • jQuery stop()
  • jQuery Callback Function
  • jQuery Chaining

jQuery HTML/CSS

  • jQuery html()
  • jQuery addClass()
  • jQuery hasClass()
  • jQuery removeClass()
  • jQuery toggleClass()
  • jQuery after()
  • jQuery before()
  • jQuery append()
  • jQuery appendTo()
  • jQuery clone()
  • jQuery insertBefore()
  • jQuery insertAfter()
  • jQuery attr()
  • jQuery text()
  • jQuery val()
  • jQuery css()
  • jQuery prepend()
  • jQuery remove()
  • jQuery empty()
  • jQuery detach()

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap