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 ();