3

I'm misunderstanding the scroll() function. I'm wishing to if a panel is open execute a function if the main window is scrolled up or down. This is my code that does nothing.

if('#specsallA:visible').scroll(function(){
              $('#specsbar').animate({
          width:'190px'
          }, '500'); $('.products').animate({
          width:'168px'
          }, '500'); $('#specsallA').hide();  $('#specsall').show();
          });

Any ideas,

Marvellous

2 Answers 2

17

A slight misunderstanding. Easiest way is to put your if() test inside the event callback

$(window).scroll(function() {
    if ($('#specsallA').is(':visible')) {
        // do your special stuff here
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

Be careful of really slowing down your site: ejohn.org/blog/learning-from-twitter
1

I think you want something more like:

$(window).scroll(function(){
   doSomething();
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.