1
我想使用jQuery刪除未添加jQuery的單擊事件處理程序。例如:使用jQuery解除未使用jQuery添加的點擊處理程序?
<a onclick="alert('This was set by onclick.')" href="#">Click me</a>
<script type="text/javascript">
$(document).ready(function(){
$("a").unbind(); // Why isn't this working?
$("a").click(function(event){
alert("This was set by jquery click.");
});
});
</script>
這可能嗎? $("a").unbind()
不起作用。上面的代碼顯示了alert()
窗口,而不僅僅是jQuery添加的窗口。我認爲unbind()
只解除與bind()
綁定的處理程序。