Skip to content Skip to sidebar Skip to footer

Jquery: This.not (':animated') && That.is (':visible') Not Following The Rules, Syntax Problem? Only Few Lines Of Code

when i click on #button, it's stilling doing the 'do something', even though .wrapper is animating and .wrapper span is not visible. so it's not following the rules. what's wrong?

Solution 1:

This is a bit cleaner without the if statements. working demo

$('#button').click(function(){ 
    $('.wrapper').filter(':animated').text("animating...");
    $('.wrapper').filter(':not(:animated)').text("not animating...");
}) 

Solution 2:

Here you have a working demo:

$('#button').click(function(){
if(    $('.wrapper:animated').length>0)
{
 $(".wrapper").text("animating")   ;
}
  if(
    $('.wrapper:animated').length<1) {
 $(".wrapper").text("not animating")   ;
  }
})

Post a Comment for "Jquery: This.not (':animated') && That.is (':visible') Not Following The Rules, Syntax Problem? Only Few Lines Of Code"