JQuery event binding function one: The Bound event processing function is executed only once. jqueryone
JQuery binds event handlers in two ways (method 1 and method 2). Method 3 is rarely used.
Method 1:
$ ("# Button"). click (function (){});
This method is very simple, and is also the most common practice of coding. The original events in HTML, such as onclick, onmouseover, and onkeypress. JQuery encapsulates the names in a simple way. For example, onclick corresponds to JQuery's click, and onmouseover corresponds to JQuery's mouseover. You can view JQuery's API and find that the event name in JQuery is basically removed from the on in the original HTML event name.
Method 2:
$ ("# Button"). bind ("click", function (){});
For details about bind/unbind, refer to this article.
Method 3:
$ ("# Button1"). one ("click", function (){});
Method 1 and Method 2: as long as the event binding is not canceled, the event processing function will be executed when a specific event occurs. In method 3, the event processing function can be executed only once at most. That is to say, event binding in method 3 is one-time, and once used, it will be useless.
The three event registration methods are not much different. If the event processing function is not required, you can use unbind to cancel the event.