HTML ondblclick Event Attribute


The ondblclick HTML event attribute specifies a JavaScript function to be executed when the user double-clicks on the element. It is part of the Event Attributes family, which can be used on any HTML element.

The ondblclick event fires after two click events, and by extension, after two pairs of mousedown and mouseup events. This means that the user must click on the element twice within a very short span of time in order for the ondblclick event to fire.

The ondblclick event can be used to perform a variety of actions, such as opening a new window, submitting a form, or playing a video. It is a common way to implement features such as image editing, text selection, and file dragging.

Here is an example of how to use the ondblclick event attribute:

<p ondblclick="alert('You double-clicked me!')">
  Double-click me!

When the user double-clicks on the <p> element, the alert() function will be called, displaying a message box with the text "You double-clicked me!".


<element ondblclick="script">


  • scriptThe name of the script to use when the event has been triggered.


<!DOCTYPE html> 
<title>Event attribute ondblclick</title>
<p id="demo2">Double-click on the button to run the script:</p>
<button ondblclick="mouseTest2()">Double click on me!</button>
function mouseTest2 () {
var x = document.getElementById ("demo2"); = "25px"; = "orange"; = "#555555";

Browser Support

The following table will show you the current browser support for the HTML ondblclick Event Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 13th October 2023