【发布时间】:2012-02-18 22:38:13
【问题描述】:
我有几个带有 id 和类选择器的元素的点击事件处理程序:
$(function() {
$("#cancelOrderLink").click(function() {
if (confirm("If you continue, all items will be removed " +
"from your cart. This action cannot be undone. Continue " +
"and empty cart?"))
$("form#clearCartForm").submit();
});
$(".updateItemLink").click(function(){
$(this).closest("form").submit();
})
});
但是,我想添加逻辑以防止在元素具有特定类名时触发这些处理程序:
$(function() {
$(".superUser").click(function() {
$("#message").html("This action is not allowed when acting as a Super User.<br />");
return false;
});
});
如何用第二个 sn-p 覆盖第一个 sn-p 中的处理程序?
【问题讨论】:
标签: javascript jquery event-handling jquery-selectors jquery-events