PHP code:
<a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a>
I want to remove the onclick="check($id,1)
so the link cannot be clicked or "check($id,1)
won't be fired. How can I do it with JQuery?
PHP code:
<a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a>
I want to remove the onclick="check($id,1)
so the link cannot be clicked or "check($id,1)
won't be fired. How can I do it with JQuery?
Old Way (pre-1.7):
New Way (1.7+):
(Replace ... with the selector you need.)
I know this is quite old, but when a lost stranger finds this question looking for an answer (like I did) then this is the best way to do it, instead of using removeAttr():
Citing jQuerys official doku:
What if onclick event is not directly on element, but from parent element? This should work:
Removing
onclick
propertySuppose you added your click event inline, like this :
Then, you can remove the event like this :
Removing
click
event listenersSuppose you added your click event by defining an event listener, like this :
... or like this:
Then, you can remove the event like this :
Removing both
If you're uncertain how your event has been added, you can combine both, like this :
Try this if you unbind the onclick event by ID Then use:
Try this if you unbind the onclick event by Class Then use:
It is very easy using removeAttr.