Home > Article > Web Front-end > The event attribute ondblclick that is triggered when the mouse double-clicks an element in html
Example
When the mouse button is double-clicked, a section of JavaScript is executed:
<button ondblclick="copyText()">Copy Text</button>Browser support
<element ondblclick="script">Attribute value
Description | |
Script that runs when ondblclick occurs. |
onclick and ondblclick two events on the same DOM element. If you follow the normal Method to add processing, it turns out that only onclick will be executed,
but not ondblclick; at this time, we need to slightly process the processing functions of the two events to achieve the coexistence of the two events. The code is as follows:<script type="text/javascript"> var clickTimer = null; function _click(){ if(clickTimer) { window.clearTimeout(clickTimer); clickTimer = null; } clickTimer = window.setTimeout(function(){ // your click process code here alert("你单击了我"); }, 300); } function _dblclick(){ if(clickTimer) { window.clearTimeout(clickTimer); clickTimer = null; } // your click process code here alert("你双击了我"); } </script> <button onclick="_click();" ondblclick="_dblclick();">单击或双击我</button>
The above is the detailed content of The event attribute ondblclick that is triggered when the mouse double-clicks an element in html. For more information, please follow other related articles on the PHP Chinese website!