MouseEvent detail Property - Javascript DOM

Javascript examples for DOM:Mouse Event

Description

The detail property returns how many times the mouse was clicked.

This property is read-only.

Return Value

A Number, representing the number of clicks.

The value for a ondblclick event is always "2"

The value for a onmouseover or onmouseout event is always "0".

The following code shows how to find out how many times the mouse was clicked.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction(event)">Click me to count</button>

<input id="myInput" type="text">

<script>
function myFunction(event) {//from   w  w  w  .j a va 2s  .  co  m
    var x = event.detail;
    document.getElementById("myInput").value = x;
}
</script>

</body>
</html>

Related Tutorials