Reputation: 16639
I have a click event
<input type="button" id="button1" value="Submit" />
$('#button1').bind('click', function(e){
e.stopPropagation();
e.stopImmediatePropagation();
alert('Loading, please wait...');
});
However, the alert
message is not prevented from showing up. How can the event be stopped before alert
.
Upvotes: 0
Views: 49
Reputation: 3840
$('#button1').bind('click', function(e){
return false;
alert('Loading, please wait...');
});
Use this.
Upvotes: 2
Reputation: 9947
You need return false;
for what are you trying to do here..
$('#button1').bind('click', function(e){
e.stopPropagation(); //stops propogation of click to parent elements
return false; //stops further execution
alert('Loading, please wait...');
});
Upvotes: 3