我想要启用/禁用元素(a或div)上的onclick
和href属性。
我不知道如何做到这一点。
我可以通过添加单击事件处理程序来禁用onclick
,但是href仍然可用。
$(this).unbind().click(function(event){
event.preventDefault();
return;
});
编辑:找到了一个元素的黑客
if ($(this).attr("href")) {
$(this).attr("x-href", $(this).attr("href"));
$(this).removeAttr("href");
}
href
属性吗? - Klemen Slavič