我可以使用jQuery删除内联事件处理程序吗? [英] Can I remove inline event handlers using jQuery?
本文介绍了我可以使用jQuery删除内联事件处理程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些带有 onclick
属性的HTML。我想使用jQuery覆盖该属性。有没有办法使用jQuery删除单击处理程序?使用取消绑定不起作用。
I have some HTML with an onclick
attribute. I want to override that attribute using jQuery. Is there any way to remove the click handler using jQuery? Using unbind doesn't work.
推荐答案
尝试 .removeAttr()
功能:
$(function() {
$('a').removeAttr('onclick');
});
一旦你摆脱了 onclick
属性,您可以附加自己的点击处理程序。
Once you've got rid of the onclick
attribute you could attach your own click handler.
这篇关于我可以使用jQuery删除内联事件处理程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文