Reputation: 8582
I have the following setup:
<div id="whatever" onclick="dostuff()">Super Mega Giga Button or Whatever</div>
<!-- Import jquery and whatever other libs I need-->
<script>
$("#whatever").click(function() { //do something });
</script>
Now what I need to do is at some point to remove all the onclick events.
I tried $("#whatever").unblind('click'); but this removes only the event added with jquery, the dostuff() function is still called.
Any idea how can I remove all at once?
P.S. Don't start asking why would some1 have inline onclick and also listeners.
Upvotes: 1
Views: 6188
Reputation: 144659
You can use the removeAttr()
method:
Remove an attribute from each element in the set of matched elements.
$('#whatever').removeAttr('onclick')
$("#whatever").click(function() {
//do something
});
Upvotes: 13