[英]How to prevent a checkbox within a table using an onclick event from propagating its own click event?
[英]Prevent a event from propagating further using jQuery
我有一個點擊事件
<input type="button" id="button1" value="Submit" />
$('#button1').bind('click', function(e){
e.stopPropagation();
e.stopImmediatePropagation();
alert('Loading, please wait...');
});
但是,不會阻止出現alert
消息。 如何在alert
之前停止事件。
您需要return false;
你打算在這里做什么
$('#button1').bind('click', function(e){
e.stopPropagation(); //stops propogation of click to parent elements
return false; //stops further execution
alert('Loading, please wait...');
});
$('#button1').bind('click', function(e){
return false;
alert('Loading, please wait...');
});
用這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.