jQuery fadeIn runs twice in its callback
javascript, jquery
Solution
It's a quick solution but not the best
var myFlag = true;
jQuery("#div1, #div2").fadeIn('300',function(){
{
if(myFlag == true)
{
// write the code here
myFlag = false;
}
}
Hope this helps... Muhammad.
Problem
``` var counter = 0; jQuery("#div1, #div2").fadeIn('300',function(){ { counter++; console.log(counter); } ``` The code above will print "1" and "2" since the jQuery fadeIn is implied on two different DOM objects. Is there anyway to cause it to run only once without breaking this code?