Standard bindings:
Bind (TYPE,[,DATA],FN) ==> The first parameter is the event type the Second optional parameter is passed as Event.data to the event object. The third parameter is the handler to bind to
Shorthand Binding Event:
$ (' #panel h5.head '). MouseOver (function () {
});
Composition Event:
Hover (enter,leave) hover event used to simulate the mouse hover event $ ('. Head '). Hover (function () {},function () {})
Toggle (FN1,FN2,FN3....FNN) $ ('. Head '). Toggle (function () {},function () {}) Toggle function also has a function to toggle the visible state of the element (' P '). Toggle ();
Event Bubbling:
<div><p><span></span></p></div> For example, adding a click event in the Div p also adds a click event span Click events are also added to trigger three click events when clicking on a span tag
This phenomenon is the event bubbling
This problem caused by event bubbling jquery provides a solution: Event.stoppropagation ();
properties of the event object:
Event.type () Gets the type of event
Event.preventdefault default events for organization browser
Event.stoppropagation Block Event bubbling
Event.target Getting event sources
Event.pagex ()/event.pagey () ==> gets the X-and y-coordinates of the cursor relative to the page
Event.which () ==> Gets the function of the mouse which key clicked 1. Left button 2. middle key 3. Right button
To remove an event:
Unbind $ (' P '). Unbind (' click ');
One TYPE,[,DATA],FN event provides a way to delete an event once it is triggered
Simulation Operation:
$ (' #btn '). Trigger (' click ');
Other operations:
To bind multiple event types at the same time:
$ (' div '). bind (' mouseover mouseout ', function () {
$ (this). Toggleclass (' over ');
})
To Add a namespace:
$ (' div '). bind (' Click.plugin ', function () {})
$ (' div '). bind (' Mouseover.plugin ', function () {})
$ (' div '). bind (' Dbclick ', function () {})
$ (' button '). Click (function () {
$ (' div '). Unbind ('. plugin ');
})
Add a namespace after the event type, so that when you delete an event, you only need to delete the namespace.
events that trigger the namespace:
$ (DIV). Trigger (' click '); ==> so there's no namespace to trigger
$ (DIV). Trigger (' click! '); ==> can only trigger an event without a namespace with an exclamation mark
jquery--Event Summary