Javascript DOM HTML Div handle mouse down event

Description

Javascript DOM HTML Div handle mouse down event

View in separate window

<!DOCTYPE html>
<html>
<body>
<div onmousedown="WhichButton(event)">Click this text with one of your mouse buttons to return a number.
</div>//from   w  ww.j  a v  a  2 s. com
<p id="demo"></p>
<script>
function WhichButton(event) {
  document.getElementById("demo").innerHTML = "You pressed button: " + event.button;
}
</script>
</body>
</html>



PreviousNext

Related