Why does my jquery function runs twice on click ?
$("a").click(processAction);
function processAction(e){
var clicked = e.target;
//show apply button.
$("#apply").live("click",function(e){
e.stopPropagation();
someFunction(clicked);
alert("this the array " + mydata);
clicked = "";
});
}
someFunction is running twice !
For every click on an a-element, you add a click handler to your #apply-element. If you click 3 times on an a-element, then click on #apply, three different instances of 'someFunction' will run.
.unbind("click").bind("click, somefunction) works beautifully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With