javascript + jquery实现定时修改文章标题
用javascript+jquery写的一个定时器,定时修改文章标题。
代码如下:
<!DOCTYPE html> <html> <head> <title>TODO supply a title</title> <meta charset="GB2312"> <meta name="viewport" content="width=device-width"> </head> <body> <div> <ul id="jokeTitle"> <li class="line">Test Line One</li> <li class="line">Test Line Two</li> <li class="line">Test Line Three</li> </ul> </div> <script type="text/javascript" src="ie/js/jquery-1.9.0.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ var changeJokeTitle = { line:3, //笑话的总行数 timeSpan:1850, //时间间隔(毫秒) interval:'', //定时器句柄,以便于停止 showLineFlag:0, //标志, change:function(){ var currentLine = (++changeJokeTitle.showLineFlag)%(changeJokeTitle.line); $('#jokeTitle li:eq('+currentLine+')').show(); $('#jokeTitle li:not(:eq('+currentLine+'))').hide(); }, run:function(){ $('#jokeTitle li:eq(0)').show(); $('#jokeTitle li:not(:eq(0))').hide(); changeJokeTitle.interval = setInterval(changeJokeTitle.change, changeJokeTitle.timeSpan); } }; changeJokeTitle.run(); }); </script> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17