只滚动一遍就停了。。求解。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<style type="text/css">

#xie{height:100px;

     overflow:hidden; 

}

#wen1{list-style-type:none;}

#wen2{list-style-type:none;}


</style>

</head>


<body>

<div id="xie">

<ul id="wen1">

<li>1</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

</ul>

<ul id="wen2">

<li>1</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

<li>2</li>

</ul>


</div>

<script>

var ding=10;

var xiao=document.getElementById("xie");

var xiao2=document.getElementById("wen1");

var xiao3=document.getElementById("wen2");

xiao2.innerHTML=xiao3.innerHTML;

function Xiemiao(){

if(wen2.offsetHeight-wen1.scrollTop<=0)

{wen1.scrollTop-=wen2.offsetHeight//demo

}

else{xie.scrollTop++;}

}

var MyMar=setInterval(Xiemiao,ding); 


</script>

</body>

</html>


xiemioc
浏览 1361回答 1
1回答

Wo可能不是我

var ding=10; var xiao=document.getElementById("xie"); var xiao2=document.getElementById("wen1"); var xiao3=document.getElementById("wen2"); function Xiemiao(){ if(xiao3.offsetHeight-xiao2.scrollTop<=0){ xiao.scrollTop-=xiao3.offsetHeight//demo } else{ if(xiao.scrollTop==xiao3.offsetHeight){ xiao.scrollTop=0; }else{ xiao.scrollTop++; } } } var MyMar=setInterval(Xiemiao,ding);这样写可以一直滚,不过你得让DIV的高度等于UL的高度
打开App,查看更多内容
随时随地看视频慕课网APP