欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js實(shí)現(xiàn)文本上下來(lái)回滾動(dòng)

 更新時(shí)間:2017年02月03日 15:58:00   作者:君邪兒  
本文主要分享了js實(shí)現(xiàn)文本上下來(lái)回滾動(dòng)的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧

話不多說(shuō),請(qǐng)看代碼:

<!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>多行滾動(dòng)jQuery循環(huán)新聞列表代碼</title>
<style type="text/css">
ul,li{margin:0;padding:0}
#scrollDiv{width:300px;height:100px;min-height:25px;line-height:25px;border:#ccc 1px solid;overflow:hidden}
#scrollDiv li{height:25px;padding-left:10px;}
</style>
<script src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
//滾動(dòng)插件
(function($){
$.fn.extend({
 Scroll:function(opt,callback){
  //參數(shù)初始化
  if(!opt) var opt={};
  var _this=this.eq(0).find("ul:first");
  var lineH=_this.find("li:first").height(), //獲取行高
   line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滾動(dòng)的行數(shù),默認(rèn)為一屏,即父容器高度
   speed=opt.speed?parseInt(opt.speed,10):500, //卷動(dòng)速度,數(shù)值越大,速度越慢(毫秒)
   timer=opt.timer?parseInt(opt.timer,10):3000; //滾動(dòng)的時(shí)間間隔(毫秒)
  if(line==0) line=1;
  var upHeight=0-line*lineH;
  //滾動(dòng)函數(shù)
  scrollUp=function(){
   _this.animate({
    marginTop:upHeight
   },speed,function(){
    for(i=1;i<=line;i++){
     _this.find("li:first").appendTo(_this);
    }
    _this.css({marginTop:0});
   });
  }
  //鼠標(biāo)事件綁定
  _this.hover(function(){
   clearInterval(timerID);
  },function(){
   timerID=setInterval("scrollUp()",timer);
  }).mouseout();
 } 
})
})(jQuery);
$(document).ready(function(){
 $("#scrollDiv").Scroll({line:1,speed:500,timer:1000});//可修改line值,speed值,timer值
});
</script>
</head>
<body>
<p>多行滾動(dòng)演示:</p>
<div id="scrollDiv">
 <ul>
 <li>這是公告標(biāo)題的第一行</li>
 <li>這是公告標(biāo)題的第二行</li>
 <li>這是公告標(biāo)題的第三行</li>
 <li>這是公告標(biāo)題的第四行</li>
 <li>這是公告標(biāo)題的第五行</li>
 <li>這是公告標(biāo)題的第六行</li>
 <li>這是公告標(biāo)題的第七行</li>
 <li>這是公告標(biāo)題的第八行</li>
 </ul>
</div>
</body>
</html>
***請(qǐng)?jiān)俅嗡⑿虏榭葱Ч?,或保存到本地瀏覽***

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論