How to remove “onclick” with JQuery?

Old Way (pre-1.7):

$("...").attr("onclick", "").unbind("click");

New Way (1.7+):

$("...").prop("onclick", null).off("click");

(Replace … with the selector you need.)

// use the "[attr=value]" syntax to avoid syntax errors with special characters (like "$")
$('[id="a$id"]').prop('onclick',null).off('click');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>


<a id="a$id" onclick="alert('get rid of this')" href="https://stackoverflow.com/questions/1687790/javascript:void(0)"  class="black">Qualify</a>

Leave a Comment