【发布时间】:2013-06-08 19:49:57
【问题描述】:
我有一个小问题,文本是可见的,它在 mouseenter 上完美滚动,在 mouseleave 上隐藏,但是当我再次将鼠标悬停时,该功能不起作用。 这是代码:
$(document).ready(function (){
var $container = $("#scrollContainer1"),
$ps = $container.find("p"),
containerHeight = $container.height(),
contentHeight = 0,
scrollTop = 0;
($container).hover(function(){
$ps.each(function() {
contentHeight += $(this).outerHeight();
})
$("<div></div>").css("height", 150).appendTo($container).clone().prependTo($container);
setInterval(function() {
if (scrollTop > contentHeight + containerHeight)
scrollTop = 0;
$container.scrollTop(scrollTop++);
}, 20);
});
($container).on("mouseleave", function(){
scrollTop=0;
contentHeight=0;
});
});
【问题讨论】:
-
@usoban -- 谢谢编辑..做噩梦了:D
-
我在这里看不到
mouseenter或mouseleave -
@passionateCoder -
.hover()是这些事件的快捷方式。 -
是的,我知道......我猜它的夜间昏昏欲睡:)