JAvascript+jqueryタイミングで記事タイトルを変更
1421 ワード
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>