Reputation: 3070
I have an HTML element:
<a id="link" href="javascript : void(0);" onclick="jsFunction();">Some Text</a>
And when a button is clicked I want the onclick attribute to be cleared. Something like
<a id="link" href="javascript : void(0);" onclick="">Some Text</a>
I tried doing this way :
document.getElementById('link').onclick="";
which didn't work.
Upvotes: 1
Views: 4251
Reputation: 9469
Use removeAttribute()
document.getElementById('link').removeAttribute('onclick');
Upvotes: 4