I've faced multiple times when I try to use .click() function that triggers the click event multiple times and have solved anyway previously and didn't noticed about this. And this time also I was facing the same problem and after an hour I noticed why this is happening. Below is an example:
wrong: (triggering click events multiple times)
$(selector).on('click',function(){
//do some func
}
$(another-selector).on('click',function(){
$(selector).click(); //trigger previous selector click function
}
right: (triggers once as expected)
$(another-selector).on('click',function(){
$(selector).click(); //trigger function before calling the function
}
$(selector).on('click',function(){
//do some func
}
selectorandanother-selector? Maybeanother-selectoris subset ofselector?another-selectoris outside theselectormarkup