jquery--Event Summary

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.