开发者

Execute function on Scroll jQuery

开发者 https://www.devze.com 2023-02-20 19:12 出处:网络
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.

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('#sp开发者_Go百科ecsallA:visible').scroll(function(){
              $('#specsbar').animate({
          width:'190px'
          }, '500'); $('.products').animate({
          width:'168px'
          }, '500'); $('#specsallA').hide();  $('#specsall').show();
          });

Any ideas,

Marvellous


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
    }
});


I think you want something more like:

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

精彩评论

暂无评论...
验证码 换一张
取 消