jQuery Type Event

Saturday, June 23, 2012

The jQuery event type property will return, when the event is triggered, which event type was triggered.


Syntax

event.type


ParameterDescription
eventSpecifies the event to check.


Example

In the following jQuery example, the type event can be used to access information about when an event is triggered. Try clicking, double-clicking, and hovering over the mouse icon below. The results will be displayed in the div element next to the mouse icon.


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#imgMouse").bind("click dblclick mouseover 
      mouseout mousedown", function (e) {
    $("#span1").html(e.type);
  });
});
</script>
</head>
<body>     
<div id="div1">Click the mouse icon to the left!</div>
</body>
</html>


mouse
The last event the mouse triggered was (waiting on first event).

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

HTML CSS and JavaScript Editor Pro jQuery JavaScript and jQuery: The Missing Manual