Lorsque je clique sur le bouton #button
, il #button
de faire le 'do something'
, même si .wrapper
est animé et la .wrapper span
n'est pas visible. Donc il ne suit pas les règles. Qu'est-ce qui ne va pas?
$('#button').click(function(){ if( $('.wrapper').not(':animated') && $('.wrapper span').is(':visible') ) { //do something } })
Ici vous avez une working demo
:
$('#button').click(function(){ if( $('.wrapper:animated').length>0) { $(".wrapper").text("animating") ; } if( $('.wrapper:animated').length<1) { $(".wrapper").text("not animating") ; } })
C'est un peu plus propre sans les instructions if. Démo de travail
$('#button').click(function(){ $('.wrapper').filter(':animated').text("animating..."); $('.wrapper').filter(':not(:animated)').text("not animating..."); })