我在jQuery代码段上出现错误,并且我不是jQuery专家。我有一个滚动div,它将使用以下功能自动滚动。
// When DOM is fully loaded
jQuery(document).ready(function ($) {
function scroll(speed) {
$('.shooter-scroller').animate({
scrollTop: $(document).height() - $('.shooter-scroller').height()
}, fast, function () {
$(this).animate({
scrollTop: 0
}, speed);
});
}
speed = 15000;
scroll(speed)
setInterval(function () {
scroll(speed)
}, speed * 2);
});
我需要用此脚本做两件事,但如果有人可以帮忙,我会希望得到一些帮助。
出于某种原因,滚动会在div的一半处停止,并且不会显示div中的所有内容,我想让滚动在到达底部时重新设置为顶部。这有可能吗?
任何帮助都将是惊人的!
小提琴:http : //jsfiddle.net/andysimps1985/gn1a2kn7/1/
提前致谢。
你需要改变
$(document).height() - $('.shooter-scroller').height()
到
$('.shooter-scroller').prop('scrollHeight')
那会给你正确的身高。参见此jsfiddle(注意:我更改了速度以获得更清晰的结果)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句