文字滚动的另一方法 拆分文字来做到文字滚动
生活随笔
收集整理的這篇文章主要介紹了
文字滚动的另一方法 拆分文字来做到文字滚动
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
最近在看javascript詳解這本書看到這個(gè)例子
文字滾動(dòng),拆分文字來(lái)做到文字滾動(dòng)。
代碼如下
<!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title>專題</title> <style type="text/css"> body{color:#333;font:12px/20px arial; background:#FFF;} body,div,form,img,p,h1,h2,dl,dt,dd,ul,li{padding:0;margin:0;} ul,li{list-style:none;} em{font-style:normal;} img{display:block;border:0} a{color:#333;text-decoration:none} a:hover,td a:hover{color:#f60;text-decoration:underline} </style><script> var message = "學(xué)習(xí)javascript將讓你的網(wǎng)頁(yè)更精彩"; message += " 你準(zhǔn)備好,學(xué)習(xí)javascript了嗎?"; var space = "..."; var position = 0; function scroller(){var newtext = message.substring(position,message.length)+space+message.substring(0,position);var con = document.getElementById("tabledata");con.firstChild.nodeValue = newtext;position++;if(position>message.length){position=0}var timer = window.setTimeout(scroller,200);con.onmouseover = function(){clearInterval(timer);}con.onmouseout = function(){timer = window.setTimeout(scroller,200);}}window.onload = function(){ scroller(); } </script> </head> <body><div id="tabledata">message goes here</div></body> </html>?
轉(zhuǎn)載于:https://www.cnblogs.com/jingangel/archive/2012/12/02/2798018.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的文字滚动的另一方法 拆分文字来做到文字滚动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: S3C6410移植u-boot-2010
- 下一篇: 网站的iphone版快开发完了