.unbind()
is deprecated and you should use the .off()
method instead. Simply call .off()
right before you call .on()
.
This will remove all event handlers:
$(element).off().on('click', function() {
// function body
});
To only remove registered 'click' event handlers:
$(element).off('click').on('click', function() {
// function body
});