我正在使用此代码:
function resizeJquerySteps() {
$('.wizard .content').animate({
height: $('.body.current').outerHeight()
}, 'slow');
}
$(window).resize($.debounce(250, resizeJquerySteps));
Run Code Online (Sandbox Code Playgroud)
并收到此错误TypeError: $.debounce is not a function
是没有错误的另一种写方法吗?
这个函数在像这样的库中定义http://benalman.com/code/projects/jquery-throttle-debounce/jquery.ba-throttle-debounce.js
您需要将此库包含到您的项目中。请参阅此处的示例http://jsfiddle.net/hYsRh/4/
$(window).scroll($.debounce( 250, true, function(){
$('#scrollMsg').html('SCROLLING!');
} ) );
Run Code Online (Sandbox Code Playgroud)