【问题标题】:Execute function on Scroll jQuery滚动jQuery上的执行功能
【发布时间】:2011-07-25 13:00:32
【问题描述】:

我误解了 scroll() 函数。如果面板打开,我希望在主窗口向上或向下滚动时执行一个功能。这是我什么都不做的代码。

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

任何想法,

太棒了

【问题讨论】:

    标签: jquery scroll jquery-animate


    【解决方案1】:

    一个小小的误会。最简单的方法是将你的 if() 测试放在事件回调中

    $(window).scroll(function() {
        if ($('#specsallA').is(':visible')) {
            // do your special stuff here
        }
    });
    

    【讨论】:

    【解决方案2】:

    我想你想要的更像是:

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

    【讨论】:

      猜你喜欢
      • 2011-02-24
      • 1970-01-01
      • 2013-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-16
      相关资源
      最近更新 更多