javascript - jQuery function issues -


i have adapted someones example (from previous stack overflow question asked) want, doesn't seem working.

if helps here link question

the function isn't working:

$(window).scroll(function(){     if ($('.orange').isonscreen() === 'true'); {         $('.box').css('background', 'red');     } }); 

here jsfiddle

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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -