The ondblclick attribute is an event-handler attribute. It runs JavaScript when the dblclick event fires — the user double-clicks an element (two rapid presses of the pointing device’s primary button on the same target).
dblclick fires after twoclick events (and after two mousedown / mouseup pairs). Prefer real <button>s for actions, and avoid making critical features double-click-only.
Baseline · Widely available.
Not deprecated and not experimental. The dblclick event is stable across modern browsers since about July 2015.
Accessibility warning.
Double-click is difficult for many users (motor, keyboard, mobile). Offer the same action with a single click or a labeled button when the action matters.
Syntax
HTML Syntax
syntax.html
<element ondblclick="script">
script is JavaScript that runs when dblclick fires. Equivalent JS: el.ondblclick = handler or el.addEventListener("dblclick", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Use <button type="button"> so activation does not submit a form.
User double-clicks the primary pointer button quickly.
dblclick fires and ondblclick runs sayReady().
Update the page — here, set a message in a paragraph.
Example 2 — Toggle a Tip with addEventListener
Preferred script pattern: show or hide content on double-click.
HTML
<button type="button" id="card" aria-expanded="false" aria-controls="tip">
Double-click to toggle tip
</button>
<p id="tip" hidden>Prefer a single-click button for important actions.</p>
<script>
var btn = document.getElementById("card");
var tip = document.getElementById("tip");
btn.addEventListener("dblclick", function () {
var open = tip.hidden;
tip.hidden = !open;
btn.setAttribute("aria-expanded", open ? "true" : "false");
});
</script>
Design carefully — if both handlers do different jobs, a double-click also runs the click handler twice.
Prefer one clear gesture for primary actions.
Edge Cases & Pitfalls
Most issues are accessibility, accidental double click side effects, or assuming touch has dblclick.
a11y
Do not hide critical actions behind double-click
Provide a single-click or keyboard-friendly control for anything important.
order
Two clicks come first
A double-click triggers two click handlers before dblclick. Avoid conflicting logic in both.
touch
Touch is unreliable for dblclick
Double-tap ≠ desktop double-click everywhere. Design mobile UX around single taps.
select
Text selection side effect
Double-clicking text often selects a word. On custom cards, consider user-select: none only when it does not hurt readability.
forms
Use type="button" in forms
A bare <button> inside a form defaults to submit. Set type="button" for non-submit actions.
Compatibility
Browser Support
ondblclick is an HTML event-handler attribute in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
ondblclick
Widely available since about July 2015. Desktop browsers support dblclick well; treat touch double-tap as a separate, less reliable gesture.
98%Global support (approx.)
Google Chrome1+
Full support
Mozilla Firefox1+
Full support
Apple Safari1+
Full support
Microsoft Edge12+
Full support
OperaAll
Full support
Samsung InternetModern · Full
Full support
Internet ExplorerAll
Supported
ondblclickWidely supported
Bottom line: Safe to use for optional desktop gestures. Prefer single-click primary actions, and use addEventListener in production.
Remember
Key Takeaways
Role: run script when the user double-clicks an element.
Order: two clicks, then dblclick.
A11y: do not require double-click for essential actions.
Apps: prefer addEventListener("dblclick", …).
One line:ondblclick is for a rapid second click — teach it, but keep primary actions on a single click.
Frequently Asked Questions
It is an event-handler attribute. When the user double-clicks an element with a pointing device (two rapid primary-button clicks), the dblclick event fires and the JavaScript in ondblclick runs.
onclick fires on each single activation. ondblclick fires after two clicks in a short time. A double-click also produces two click events before dblclick.
Double-tap is not the same as dblclick on all devices. Many touch UIs do not expose a reliable double-click. Prefer a clear single-tap control for important actions.
Often not ideal. Double-click is hard for many keyboard, motor, and mobile users. Offer the same action with a single click or an explicit button when the action matters.
Both work. For learning, ondblclick in HTML is fine. In production code, prefer element.addEventListener("dblclick", handler).
No. The dblclick event and ondblclick handler are standard and Baseline widely available since about July 2015.