javascript - jQuery function issues -
i have adapted someones example (from previous stack overflow question asked) want, doesn't seem working.
the function isn't working:
$(window).scroll(function(){ if ($('.orange').isonscreen() === 'true'); { $('.box').css('background', 'red'); } });
when orange square comes screen, rest of squares should change red, , when orange square not on screen, red squares need turn blue again.
there few problems in syntax, this, though unoptimized, should work
$(window).scroll(function(){ //isonscreen returns boolean, loose comparison if ($('.orange').isonscreen()){ $('.box').css('background', 'red'); } else { //you need revert when isonscreen returns false $('.box').css('background', 'blue'); } });
Comments
Post a Comment