Computer >> Computer tutorials >  >> Programming >> HTML

Execute a script when the element is being double-clicked in HTML?


Use the ondblclick attribute in HTML to execute a script when the element is being double-clicked in HTML.

Example

You can try to run the following code to implement the ondblclick attribute −

<!DOCTYPE html>
<html>
   <body>
      <button ondblclick = "display()">Click me twice</button>
      <script>
         function display() {
            alert("You double-clicked the button!");
         }
      </script>
   </body>
</html>