Four ways to bind events in jQuery, they can bind one or more events at the same time
bind() ------------------------------------------------------------------------------------------------------------------------------
live()-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
delegate() ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on()-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A: Usage of bind() event
<title>Binding events</title> <script src="js/jQuery1.11." type="text/javascript"></script> <script> $(function () { $("p").bind({ "mouseover": function () { $("p").css("background-color", "red"); }, "mouseout": function () { $("p").css("background-color", ""); } }); }); </script> </head> <body> <p>what are you doing?</p> </body> </html>
The first biggest difference is that the event binding of bind() is only valid for the elements selected on the current page. If you want to create dynamically for the bind() event of the element, there is no way to achieve the effect.
In the subsequent dynamic generation of DOM element binding events, you must use on();
The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!