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?
PS Don't start asking why would some1 have inline onclick and also listeners.
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
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.