I’m working with a simple animation instruction:
$('.slide').stop().animate({ queue: true, marginTop: total + 'px' }, (2000 * 2 * times), function () {
alert('in');
});
Where the marginTop of a <div class="slide"></div> is being manipulated.
Now, the issue comes here:
As you can see, the app should only show ONE alert saying “IN”, because the alert
is performed in the animation-end function. However, the alert is being shown more than
once…
why?
p.s: I don’t have loops or so in my code…
Thx
The only reason for this is that you have more than one element in your markup which owns a classname of
slide. jQuery will apply that animation to each element which was queried by your selector.Unless you don’t possibly call that code multiple times of course.