jQuery.fn.extend({
scrollTo : function(speed, easing) {
return this.each(function() {
var targetOffset = $(this).offset().top;
$.fx.off = true;
$('html,body').animate({scrollTop: targetOffset}, speed, easing);
});
}
});
$(document).keyup(function(e)
{
if(e.keyCode == 78) {
navigation_x();
}
function navigation_x(){
$('div#images-interface-controller').scrollTo(1000);
}
所以我有這個按鍵功能,每次我按字母「n」它將滾動到div#images-interface-controller,是滾動,但直到'到最後一個元素div#images-interface-controller。我怎麼能阻止它,我的意思是我希望它每次按「n」時只滾動一次。我想上面的jQuery代碼的問題與我的問題有關。任何幫助將不勝感激。謝謝!jquery滾動所有分區
不管怎麼說,我使用這個插件: http://flesler.blogspot.com/2007/10/jqueryscrollto.html
只需要滾動到ID的數組,然後按下「n」按鈕循環通過它們... – Chad 2012-07-22 15:06:16