Reputation: 103
I'ts possible to unbind the previos events of a button ,something like that
$("#my-button").on('click',function(){
$( "#my-button" ).unbind();
alert('whatever');
});
Upvotes: 1
Views: 186
Reputation: 279
$( "#my-button" ).unbind("click");
click can be any event we want to unbind.
unbind need to know which event it has to unbind.
Upvotes: 0
Reputation: 5788
You can unbind click using .unbind() or .off()
$( "#my-button" ).unbind( "click" );
Upvotes: 1
Reputation: 4271
Try this:
$("#my-button").off('click').on('click',function() {
alert('whatever');
});
Documentation for jQuery off
The .off() method removes event handlers that were attached with .on()
Upvotes: 0