我遇到了一个问题,我想使用相同的功能在窗口内使用 ScrollTop,但“0”或“-=10”不起作用。你明白为什么吗?如果我发出警报,它会识别类“monter”,但它永远不会上升到“0”或“-=10”。这是我的代码:
function scroll_descendre(){
var scrolling;
$('.descendre, .monter').bind({
mousedown: function(){
var zone = $(this).prev();
scrolling = true; //this is here :
if ($(this).attr('class')=='descendre') startScrolling(zone, '+=20');
else if($(this).attr('class')=='monter') startScrolling(zone, '0');
},
mouseup: function(){
scrolling = false;
},
click: function(e){
e.preventDefault();
}
});
function startScrolling(obj, param){
if (!scrolling) {
obj.stop();
} else {
obj.animate({"scrollTop": param}, "fast", function(){
if (scrolling) { startScrolling(obj, param); }
});
}
}
}
谢谢你的帮助