为什么script写在<heard></heard>标签内不可用,要放在</body>前了?之前学的不都是写在<heard></heard>标签内的吗?
信息滚动效果制作,为什么script写在<heard></heard>标签内不可用,要放在</body>前了?之前学的不都是写在<heard></heard>标签内的吗?
信息滚动效果制作,为什么script写在<heard></heard>标签内不可用,要放在</body>前了?之前学的不都是写在<heard></heard>标签内的吗?
2016-04-16
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>无缝滚动</title>
<style>
*{
margin:0px;
padding:0px;
}
#bos{
width: 500px;
height:200px;
border:1px solid #000;
overflow: hidden;
}
#bos li{
height: 24px;
}
</style>
</head>
<body>
<div id="bos">
<ul id="ul1">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
<ul id="ul2"></ul>
</div>
<script>
var bos = document.getElementById("bos");
var ul1 = document.getElementById("ul1");
var ul2 = document.getElementById("ul2");
bos.scrollTop=0;
ul2.innerHTML=ul1.innerHTML;
var dea = 50;
setInterval("fun()", dea);
function fun(){
bos.scrollTop++;
if(bos.scrollTop>=ul1.scrollHeight){
bos.scrollTop=0;
}
}
</script>
</body>
</html>
举报