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
The execution order is different. The unbind in onload is executed after the bind below, so you bind first, then unbind after onload
You bound a click event to the input, but the click event was removed from your window.onload