I have a jquery code to set the click event as follow: $("#somediv").click(function() {alert('test')});
How do I remove the above click event? it seems that the .click() method will always append the exisiting ones.
Use
$('#somediv').unbind('click');
If you only want to remove that function, you need a reference to it:
var test = function() {alert('test');};
$("#somediv").click(test);
window.setTimeout(function () {
$('#somediv').unbind('click', test);
}, 10000);
http://api.jquery.com/unbind/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With