[JS] [23] on () event and bind off () unbind event

text:

Note: The binding event element off the lift, which must be consistent with the choice of binding events and on the use of selectors

html:

<input id="btn1" type="button" value="点击1" />
<input id="btn2" type="button" value="点击2" />
<a id="a1" href="#">CodePlayer</a>

JS:

// to bind 1 button click event 
$ body.on ( "the Click", "# btn1" , btnClick1);
 function btnClick1 () { 
} 

// Remove button click event 1 
$ body.off ( "click", "# btn1" ); 

// error: selector inconsistent, unable to unbind 
$ body.off ( "click", " : button");

Reference blog:

On the jquery on () event and bind off () unbind event _jquery_ script home
https://www.jb51.net/article/95723.htm

Guess you like

Origin www.cnblogs.com/huashengweilong/p/10961795.html
Recommended