1.event.currenttarget//the current DOM element in the event bubbling phase
$ ("P"). Click (Function (event) { alert (event.currenttarget = = = this);//True });
2.event.data//the currently executing processor is bound, contains optional data to be passed to JQuery.fn.bind.
$ ("a"). each (function (i) { $ (the). bind (' click ', {index:i}, function (e) { alert (' My index is ' + E.data.index); c5/>});
3.event.delegatetarget//when Currently-called's jquery event handler attaches an element.
$ (". Box"). On ("Click", "button", function (event) {
$ (event.delegatetarget). CSS ("Background-color", "Red");
Binds the Click event to all span elements in an element with ID elements
$("#element").On( "Click", "Span", function(Event){
Event.delegatetarget is the DOM element with ID element
This is the span element for the current triggering event
Alert(Event.Delegatetarget=== This); False
} );
Binds the Click event to all span elements in an element with ID elements
$("#element span"bind ( "click" , function (event
//Event.delegatetarget is the span element of the current triggering event //this is the span element of the current triggering event
Alert ( Event. Delegatetarget === this //true
}
4.event.isdefaultprevented ()//Returns a Boolean value based on whether the Event.preventdefault () method is called in the event object
$ ("a"). Click (Function (event) { alert (event.isdefaultprevented ());//False Event.preventdefault (); Alert (event.isdefaultprevented ()); True });
5.event.isimmediatepropagationstopped ()//Returns a Boolean value based on whether the Event.stopimmediatepropagation () method is called in the event object.
function immediatepropstopped (e) { var msg = ""; if (e.isimmediatepropagationstopped ()) { msg = "called"; } else { msg = "not called"; } $ ("#stop-log"). Append ("<div>" + msg + "</div>"); } $ ("button"). Click (Function (event) { immediatepropstopped (event); Event.stopimmediatepropagation (); Immediatepropstopped (event); });
6.event.ispropagationstopped ()//Returns a Boolean value based on whether the Event.stoppropagation () method is called in the event object.
function propstopped (e) { var msg = ""; if (e.ispropagationstopped ()) { msg = "called"; } else { msg = "not called"; } $ ("#stop-log"). Append ("<div>" + msg + "</div>"); } $ ("button"). Click (Function (event) { propstopped (event); Event.stoppropagation (); Propstopped (event); });
7.event.namespace//This property contains the specified namespace when an event is triggered.
$ ("P"). Bind ("Test.something", function (event) { alert (event.namespace); }); $ ("button"). Click (Function (event) { $ ("P"). Trigger ("test.something"); });
8.event.pagex//the position of the mouse relative to the left edge of the document.
event.pagex//the position of the mouse relative to the left edge of the document.
$ (document). Bind (' MouseMove ', function (e) { $ ("#log"). Text ("E.pagex:" + E.pagex + ", E.pagey:" + e.pagey); });
9.event.preventdefault ()//prevents triggering of default event behavior.
$ ("a"). Click (Function (event) { event.preventdefault (); $ (' <div/> '). Append (' default ' + Event.type + ' prevented '). AppendTo (' #log '); });
10.event.relatedtarget//any other DOM elements involved in the event
For the Mouseout event, it points to the element being entered; for the Mousein event, it points to the element being left.
$ ("a"). Mouseout (function (event) { alert (event.relatedTarget.nodeName);//"DIV"
11.event.result//This property contains the return value of the handler function that was last triggered by the current event event, unless the value is undefined.
$ ("button"). Click (Function (event) { return "Hey"; }); $ ("button"). Click (Function (event) { $ ("P"). html (event.result); });
12.event.stopimmediatepropagation ()//prevents the remaining event handlers from being executed and prevents events from bubbling onto the DOM tree.
$ ("P"). Click (Function (event) { event.stopimmediatepropagation (); }); $ ("P"). Click (Function (event) { //This function won ' t is executed $ (this). CSS ("Background-color", "#f00"); }); $ ("div"). Click (Function (event) { //This function is executed $ (this). CSS ("Background-color", "#f00 "); });
13.event.stoppropagation ()//prevents events from bubbling to the DOM tree, that is, event handlers on any predecessor elements that are not triggered.
$ ("P"). Click (Function (event) { event.stoppropagation (); Do something });
14.event.target//the DOM element that initially triggered the event.
function Handler (event) { var $target = $ (event.target); if ($target. is ("Li")) { $target. Children (). Toggle (); } } $ ("ul"). Click (Handler). FIND ("ul"). Hide ();
15.event.timestamp//This property returns the number of milliseconds from January 1, 1970 when the event was triggered.
var last, diff; $ (' div '). Click (Function (event) { if (last) { diff = event.timestamp-last; $ (' div '). Append (' time since last event: ' + diff + ' <br/> '); } else { $ (' div '). Append (' Click again.<br/> '); } last = Event.timestamp; });
16.event.type//Event Type
$ ("a"). Click (Function (event) { alert (event.type);//"Click"
17.event.which//for keyboard and mouse events, this generic performance determines which key or button you are pressing.
<script> $ (' #whichkey '). Bind (' KeyDown ', function (e) { $ (' #log '). HTML (e.type + ': ' + E.which); } ); </script>
jquery slowly gnawing event object (11)