1

我有两个小提琴。

在第一个 Fiddle 中,debounce 运行良好:

http://jsfiddle.net/hYsRh/4/

但是当我稍微修改它时,去抖动不能正常工作:

http://jsfiddle.net/hYsRh/272/

谁能告诉我第二个debouce Fiddle有什么问题?

我希望在第二小提琴中使用这种格式的脚本,在这样的滚动功能下:

$(window).on('scroll', function() 
{

});
4

1 回答 1

2

不要将代码添加为回调函数,将其添加为语句:使用以下代码:

$(window).on('scroll', $.debounce( 250, true, function(){
    $('#scrollMsg').html('SCROLLING!');
} ));
  $(window).on('scroll', $.debounce( 250, function(){
    $('#scrollMsg').html('DONE!');
} ));

演示

于 2015-04-02T08:45:29.073 回答