type Event Property - Javascript DOM

Javascript examples for DOM:Event

Description

The type event property returns the event type.

Return Value

A String, representing the type of the event

The following code shows how to Return the type of event that was triggered:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body
  onmousedown="myFunction(event)"
  onmouseup="myFunction(event)"
  onkeydown="myFunction(event)"
  onkeyup="myFunction(event)">

<p>Press any key or click the mouse in this document.</p>

<p>Event: <span id="demo"></span></p>

<script>
function myFunction(event) {//from   w w w.  ja  va  2s  .  c  o  m
    var x = event.type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials