I am firing click event inside the loop.it fires multiple times .
How can i stop firing multiple time.
My code:-
var myArray = [1,2,3,4,5,6];
var i;
for(i=0;i<myArray.length;i++){
$(".Mydiv").click(function(){
alert(myArray[i]);
});
}
just example code.
Actually, I am updating every second Mydiv attr id using jQuery attr to get current user.
so when i click mydiv i should only get the current user id. but i fires all.
Thanks
If I understood you well, this is the solution:
Hope this helps. Cheers