JS實現(xiàn)的新聞列表自動滾動效果示例
本文實例講述了JS實現(xiàn)的新聞列表自動滾動效果。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
#box{width:260px;height:100px;margin:0 auto;border:2px solid red;overflow: hidden}
ul{padding:0;margin:0;list-style: none;overflow: hidden}
ul li{height:24px;line-height: 24px;padding-left:10px;}
a{text-decoration: none;color:#000;}
a:hover{color:#f00}
</style>
</head>
<body>
<div id="box">
<ul id="con1" onMouseOut="Up()" onMouseOver="Stop()">
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >1,課程html</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >2,課程css</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >3,課程js</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >4,課程jquery</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >5,課程html5</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >6,課程css3</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >7,課程hp</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >8,課程bpootstrap</a> </li>
<li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >9,課程apicloud</a> </li>
</ul>
<ul id="con2"></ul>
</div>
</body>
<script type="text/javascript">
var box=document.getElementById("box");
var con1=document.getElementById("con1");
var con2=document.getElementById("con2");
var s=document.getElementsByTagName("a");
var speed=50;
con2.innerHTML=con1.innerHTML;
function ScrollUp(){
if( box.scrollTop>=con1.scrollHeight){
box.scrollTop=0;
}else
box.scrollTop++;
}
var i=setInterval("ScrollUp()",speed);
function Stop(){
clearInterval(i);
}
function Up(){
i=setInterval("ScrollUp()",speed);
}
</script>
</html>
這里使用在線HTML/CSS/JavaScript代碼運(yùn)行工具:http://tools.jb51.net/code/HtmlJsRun測試上述代碼,可得如下運(yùn)行效果:

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對大家JavaScript程序設(shè)計有所幫助。
相關(guān)文章
countup.js實現(xiàn)數(shù)字動態(tài)疊加效果
這篇文章主要為大家詳細(xì)介紹了countup.js實現(xiàn)數(shù)字動態(tài)疊加效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-10-10
layui在form表單頁面通過Validform加入簡單驗證的方法
今天小編就為大家分享一篇layui在form表單頁面通過Validform加入簡單驗證的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09
js拖動div 當(dāng)鼠標(biāo)移動時整個div也相應(yīng)的移動
要拖動的div為最外層的div,這段代碼對顯示對話框的頭部綁定鼠標(biāo)監(jiān)聽事件,當(dāng)鼠標(biāo)移動時,整個div也相應(yīng)的移動,具體的實現(xiàn)如下,感興趣的朋友可以參考下2013-11-11
uniapp介紹與使用以及小程序?qū)崟r獲取視頻播放時間
這篇文章主要給大家介紹了關(guān)于uniapp介紹與使用以及小程序?qū)崟r獲取視頻播放時間的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用uniapp具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2023-02-02

