function slide2(){
var elem=$("#p2_box");
var top=elem.scrollTop();
top=top+line_h*0.05;
if(top>=height_1+height_2)
elem.scrollTop(0)
else
elem.scrollTop(top);
var timeout=setTimeout(arguments.callee,60)
elem.mouseover(function(){
clearTimeout(timeout);
}).mouseout(function(){
setTimeout(aslide2,100)////为什么鼠标离开后浏览器卡住了
})
}
slide2();
我想让一段文章向上慢慢滚动,当鼠标停留时,其暂停滚动,离开时,继续滚动,问题是,为什么我鼠标停留离滚动的越来越快,最后浏览器卡了??
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不论鼠标指针离开指定元素还是该元素子元素,都会触发 mouseout 事件。(冒泡)
只有在鼠标指针离开指定元素时,才会触发 mouseleave 事件。(不冒泡)
此外mouseenter和mouseover也是一个冒泡一个不冒泡。
越来越快到最后浏览器卡住了有可能是因为事件冒泡之后执行了很多次,建议你打个断点一步一步看。