我似乎無法得到這個停止傳播..jQuery on()stopPropagation不工作?
$(document).ready(function(){
$("body").on("click","img.theater",function(event){
event.stopPropagation();
$('.theater-wrapper').show();
});
// This shouldn't fire if I click inside of the div that's inside of the
// `.theater-wrapper`, which is called `.theater-container`, anything else it should.
$(".theater-wrapper").click(function(event){
$('.theater-wrapper').hide();
});
});
我所有的內容都是通過AJAX –
加載到頁面@DylanCross - 在這種情況下,你應該使用哪一個我在答覆中提到的另一種方法。保持「on」事件處理的原樣。 – ShankarSangoli
是的,當我點擊的時候點擊它不應該關閉的位置時它仍然關閉。 –