禁用(并重新启用)href和onclick元素 [英] Disable (and re-enable) the href and onclick on elements
本文介绍了禁用(并重新启用)href和onclick元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在元素(a或div)上启用/禁用onclick和href。
I just want to enable / disable onclick and href on elements (a or div).
我不知道该怎么做。
我可以通过在点击事件上添加处理程序来禁用onclick,但是href仍然可用。
I can disable onclick by adding an handler on click event, but the href is still available.
$(this).unbind().click(function(event){
event.preventDefault();
return;
});
编辑查找元素的内容
if ($(this).attr("href")) {
$(this).attr("x-href", $(this).attr("href"));
$(this).removeAttr("href");
}
推荐答案
好的我找到了解决方法:在主div上放置一个叠加层,其中包含我要禁用的所有元素..
它只是有效。
Ok i've found a workaround : putting an overlay over the main div containing all the elements i wanted to disable .. It just works.
这篇关于禁用(并重新启用)href和onclick元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文