jquery events-Bindings and unbinding

Source: Internet
Author: User

One, on () multi-event binding
$ ("#elem"). On ("MouseOver mouseout", function () {}); Multiple events bind a function
$ ("#elem"). On ({              //multiple event bindings for different functions    mouseover:function () {},      mouseout:function () {}});
<div class= "Left" >    <p class= "Aaron" >        <a> Target node </a>//Click on this element    </p></ Div>
$ ("div"). On ("click", "P", FN)
Events are bound to the topmost div element, and when the user fires on the A element, the event will bubble up and will always bubble on the div element.
If a second parameter is provided, the event callback function is triggered when the events encounter a selector-matched element p in the bubbling process.

Second, unload event off () method
    • Event handlers that are bound by the. On ()
    • Remove the binding through the off () method

Depending on the characteristics of the on binding event, the off method can also remove the event handler specified on the element by passing the corresponding combination of event name, namespace, selector, or handler function.

When there are multiple filter parameters, only event handlers that exactly match those parameters will be removed

$ ("BTN"). Click (function () {   $ (". Aaron:first"). Off (' MouseDown ');//Remove mouse down event})

jquery events-Bindings and unbinding

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.