Similarities and differences between bind () on () live () one () in jQuery, jquerybind

Source: Internet
Author: User

Similarities and differences between bind () on () live () one () in jQuery, jquerybind

 

Four Methods for binding events in jQuery. They can bind one or more events at the same time.

Bind () ------------------------- version less than 3.0 (removed in Jquery3.0 and unbind)

Live () -------------------------- version less than 1.7 (removed from Jquery1.7 and the corresponding die)

Delegate () ------------------- version less than 1.7 (removed from Jquery1.7)

On () --------------------------- the version number is greater than 1.7 (add in Jquery1.7 and add the corresponding off)

 

 

A: bind () event usage

<Title> bind events </title> <script src = "js/jQuery1.11.1.js" type = "text/javascript"> </script> <script >$ (function () {$ ("p "). bind ({"mouseover": function () {$ ("p" ).css ("background-color", "red") ;}, "mouseout": function () {$ ("p" ).css ("background-color ","");}});}); </script> 

The first biggest difference is that bind () event binding is only valid for the selected elements on the current page. If you want to dynamically create element bind () events, there is no way to achieve the effect.

 

To dynamically generate DOM element binding events, you must use on ();

 

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.