多个选择器在单击事件上调用相同的 jquery 方法。
我必须根据第一次事件调用验证的某些条件防止其他事件进一步调用该方法。
var once = false;
var myFunction = function(e){
if(!once){
once = true;
// executed first time
}else{
// executed after first time
}
}
$(selector).click(myFunction)
This will disable the event handlers for all elements after any one of the elements has been clicked
$("#parent").on("click",".elementToClick",function(){
$('#parent').off();
// plus whatever else you need to do
});