After unbinding first, bind sometimes fails. Some business requirements no longer need to be bound, and some need to be re-bound.
The following is a simple example
window.onload=function(){
$("input").unbind();
}
$("input").bind("click",function(){
alert("1");
})
This cannot be rebinded
Written like this, you can bind
$("input").unbind();
$("input").bind("click",function(){
alert("1");
})
Ask the reason for this problem? Expert analysis
PHP中文网2017-06-26 11:00:53
The execution order is different. The unbind in onload is executed after the bind below, so you bind first, then unbind after onload
伊谢尔伦2017-06-26 11:00:53
You bound a click event to the input, but the click event was removed from your window.onload