i am having a problem when i click on an input(button) (click event captured using jquery) it is executed two times but the click event is single... i used "e.stopPropagation();" - but it didn't work...
jQuery("#ok").click(function(e){
alert("Alert");
e.stopPropagation();
});
i need the reason and the solution...
take care..
i am having a problem when i click on an input(button) (click event captured using jquery) it is executed two times but the click event is single... i used "e.stopPropagation();" - but it didn't work...
jQuery("#ok").click(function(e){
alert("Alert");
e.stopPropagation();
});
i need the reason and the solution...
take care..
Share Improve this question edited Dec 28, 2010 at 7:46 Jamal Abdul Nasir asked Dec 28, 2010 at 7:21 Jamal Abdul NasirJamal Abdul Nasir 2,6675 gold badges31 silver badges47 bronze badges 3- 1 post your code...so that we can understand whats going on... – Vivek Commented Dec 28, 2010 at 7:23
- May be you somehow ran this click-setup code twice? – Maxim Sloyko Commented Dec 28, 2010 at 8:06
- @maksymko... no brother just once.. – Jamal Abdul Nasir Commented Dec 28, 2010 at 8:14
5 Answers
Reset to default 10problem is solved...
i just added e.stopImmediatePropagation();
to the click function... and it worked... None of the following functions worked...
e.preventDefault();
e.stopPropagation();
return false
---------------------CODE---------------------
jQuery("#ok").click(function(e){
alert("Alert");
e.stopImmediatePropagation();
});
Click here for more information on jQuery Events..
Please use e.stop(true,true)
and function which you are using. like
e.stop(true,true).show();
I think you use this code as below:
jQuery("#ok").click(function(){
alert("Alert");
return false;
});
e.preventDefault()
is likely what you are looking for.
i used
return false;
after the desired action.