You need to use filter() instead of is() because is()
returns a boolean value which will cause an error
$(this).filter(".block-left").addClass('fadeInLeft');
$(this).filter(".block-right").addClass('fadeInRight');
Domanda
/* If the object is completely visible in the window... */
if( bottom_of_window > bottom_of_object ){
$(this).is(".block-left").addClass('fadeInLeft');
$(this).is(".block-right").addClass('fadeInRight');
}
I wand to addClass by checking the elements class, but this doesn't seem to work.
Altri suggerimenti
You can use hasClass():
if( bottom_of_window > bottom_of_object ){
if($(this).hasClass("block-left")) {
$(this).addClass("fadeInLeft");
} else if($(this).hasClass("block-right")) {
$(this).addClass("fadeInRight");
}
}
You have to use if
if( bottom_of_window > bottom_of_object ){
if ($(this).is(".block-left")) {
$(this).addClass('fadeInLeft');
} else if ($(this).is(".block-right"))
$(this).addClass('fadeInRight');
}
}
Use .hasClass()
if($(this).hasClass("block-left")){
$(this).addClass('fadeInLeft');
}