html js setinterval clearinterval 不断滚动的DIV问题
我想实现自动滚动,鼠标移上去停止,下面这个怎么老是不能实现额?真心求大虾教导!!不用onmouse的话interval能实现,就只有鼠标动作不能实现,貌似不响应!#scr...
我想实现自动滚动,鼠标移上去停止,下面这个怎么老是不能实现额?真心求大虾教导!!不用onmouse的话interval能实现,就只有鼠标动作不能实现,貌似不响应!
#scrollframe{
width:228px;
height:245px;
overflow:hidden;
position:relative;
}
#scrollcontent{
width:228px;
position:absolute;
left:0;
top:0;
}
<script>
window.onload=function(){
var ScrollContent = document.getElementById("scrollcontent");
}
function fn(){
ScrollContent.style.top=ScrollContent.offsetTop-1+"px";
if(ScrollContent.offsetTop<=-6*63){
ScrollContent.style.top = 0+"px";
}
}
function setInt(){
inter=setInterval(fn,50);
}
</script>
<div id="scrollframe">
<div id="scrollcontent" style=" top:0;" onmouseover="clearInterval(inter);" onmouseout="setInt();">
内容
</div>
</div> 展开
#scrollframe{
width:228px;
height:245px;
overflow:hidden;
position:relative;
}
#scrollcontent{
width:228px;
position:absolute;
left:0;
top:0;
}
<script>
window.onload=function(){
var ScrollContent = document.getElementById("scrollcontent");
}
function fn(){
ScrollContent.style.top=ScrollContent.offsetTop-1+"px";
if(ScrollContent.offsetTop<=-6*63){
ScrollContent.style.top = 0+"px";
}
}
function setInt(){
inter=setInterval(fn,50);
}
</script>
<div id="scrollframe">
<div id="scrollcontent" style=" top:0;" onmouseover="clearInterval(inter);" onmouseout="setInt();">
内容
</div>
</div> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询