Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double execution on a single click jquery

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..

like image 322
Jamal Abdul Nasir Avatar asked Dec 02 '22 03:12

Jamal Abdul Nasir


2 Answers

problem 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..

like image 90
Jamal Abdul Nasir Avatar answered Dec 15 '22 02:12

Jamal Abdul Nasir


Please use e.stop(true,true) and function which you are using. like

e.stop(true,true).show();
like image 24
Vijay Karamchandani Avatar answered Dec 15 '22 03:12

Vijay Karamchandani