Javascript DOM ondblclick Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("dblclick",
       myScript);

This example uses the addEventListener() method to attach a "dblclick" event to a p element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="demo">Double-click me.</p>
<script>
document.getElementById("demo").addEventListener("dblclick", myFunction);
function myFunction() {//  w ww. j  ava 2 s  . c o  m
  document.getElementById("demo").innerHTML = "I was double-clicked!";
}
</script>

</body>
</html>
Bubbles:
Yes
Cancelable:
Yes
Event type:
MouseEvent
Supported HTML tags:












All HTML elements,
EXCEPT:
<base>,
<bdo>,
<br>,
<head>,
<html>,
<iframe>,
<meta>,
<param>,
<script>,
<style>, and
<title>.



PreviousNext

Related