Javascript + jquery to regularly modify the title of the article

  • 2020-03-30 02:25:30
  • OfStack

Using javascript+jquery to write a timer, regularly modify the title of the article.

<!DOCTYPE html> 
<title>TODO supply a title</title> 
<meta charset="GB2312"> 
<meta name="viewport" content="width=device-width"> 

<ul id="jokeTitle"> 
<li class="line">Test Line One</li> 
<li class="line">Test Line Two</li> 
<li class="line">Test Line Three</li> 
<script type="text/javascript" src="ie/js/jquery-1.9.0.min.js"></script> 
<script type="text/javascript"> 

var changeJokeTitle = { 
line:3, //Total number of lines of jokes
timeSpan:1850, //Time interval (milliseconds)
interval:'', //Timer handle for easy stopping
showLineFlag:0, //Mark,

var currentLine = (++changeJokeTitle.showLineFlag)%(changeJokeTitle.line); 

$('#jokeTitle li:eq('+currentLine+')').show(); 
$('#jokeTitle li:not(:eq('+currentLine+'))').hide(); 
$('#jokeTitle li:eq(0)').show(); 
$('#jokeTitle li:not(:eq(0))').hide(); 
changeJokeTitle.interval = setInterval(changeJokeTitle.change, changeJokeTitle.timeSpan); 



Related articles: