单条文字向上滚动--jq特效
<!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>单条文字向上滚动--jq特效</title>
<script src="js/jquery.1.4.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//搜索下文字向上滚动
dMarquee('scroll');
function dMarquee(id){
var speed=18; //速度
var stop=5000; //停止时间
var ul = document.getElementById(id);
var rows=ul.getElementsByTagName('li').length;
var height = ul.getElementsByTagName('li')[0].offsetHeight;
ul.innerHTML += ul.innerHTML;
var timeID = false;
var play = function() {
ul.scrollTop++;
if(ul.scrollTop==rows*height){
ul.scrollTop=0; }
if(ul.scrollTop%height==0)
{ timeID = setTimeout(play,stop); }
else{ timeID = setTimeout(play,speed);}
}
timeID = setTimeout(play,stop);
ul.onmouseover = function() {clearTimeout(timeID);}
ul.onmouseout = play;}
});
</script>
<style type="text/css">
ul,li{ margin:0px; padding:0px;}
.n{ float:left; /*height:38px; line-height:38px; */padding-left:6px; overflow:hidden;}
.n a{ font-size:12px; font-family:"新宋体"; font-weight:bold; line-height:38px;color:#000; }
.n ul{ list-style:none; height:38px; overflow:hidden;}
.n ul li{ height:38px;overflow:hidden;}
</style>
</head>
<body>
<div class="n">
<ul id="scroll">
<li><a href="#">10元RMB百人观影 2013.01.26</a></li>
<li><a href="#">20元RMB百人观影 2013.01.26</a></li>
<li><a href="#">30元RMB百人观影 2013.01.26</a></li>
<li><a href="#">40元RMB百人观影 2013.01.26</a></li>
<li><a href="#">50元RMB百人观影 2013.01.26</a></li>
</ul>
</div>
</body>
</html>
上一篇:jQuery中判断一个元素是否为另一个元素的子元素(或者其本身)
下一篇:jquery设置元素的readonly和disabled
讨论数量:0