JavaScript 文字无间断上下滚动

<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>文字无间断滚动效果</title>
</head>
<body>
<div id="demo" onmouseover="clearInterval(timer)" onmouseout="timer=setInterval(mar,30)" style="overflow:hidden; height:30px; width:100px;">
<div id="demo1">
欢迎你来到China祥的个人博客

欢迎再次光临

祝您愉快
</div>
<div id="demo2">
</div>
</div>
<script>
	var t=getid("demo"),t1=getid("demo1"),t2=getid("demo2"),sh=getid("show"),timer;
	t2.innerHTML=t1.innerHTML;
	function mar(){
		if(t2.offsetTop<=t.scrollTop){
			t.scrollTop-=t1.offsetHeight;
		}else{
			t.scrollTop++;
		}
	}
	timer=setInterval(mar,30);
	function getid(id){
		return document.getElementById(id);
	}
</script>

</body>
</html>

 

你可能感兴趣的:(JavaScript)