Javascript DOM MouseEvent detail Property

Introduction

Find out how many times the mouse was clicked in the same area:

Click the button to display the current click count of the clicked button.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction(event)">Click count:</button>

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

<script>
function myFunction(event) {//  w w w .  ja va  2  s .c om
  var x = event.detail;
  document.getElementById("myInput").value = x;
}
</script>

</body>
</html>

The detail property returns a number with details about the event.

When used on onclick and ondblclick, the number indicates the current click count.

When used on onmousedown and onmouseup,the number indicates the current click count plus 1.

This property is read-only.

The returned value for a ondblclick event is always "2".

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




PreviousNext

Related