Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript 2 images activate the same animation, how would you ensure that the animation happens only once? Re: 2 images activate the same animation, how would you ensure that the animation happens only once?

#137752
Smitty
Member

You could set a variable with either true or false as it’s value, and check that before you animate.

rough example

var hovered = false;

if ( !hovered){

$(‘#hoverElement’).mouseOver(function(){
hovered = true;
});
$(‘#hoverElement’).mouseOut(function(){
hovered = false;
});
}