Javascript + jquery implement regular article title Modification

Source: Internet
Author: User

Use a timer written in javascript + jquery to regularly modify the article title.
Copy codeThe Code is as follows:
<! 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, // The total number of jokes
TimeSpan: 1850, // time interval (MS)
Interval: '', // timer handle for ease of stopping
ShowLineFlag: 0, // flag,
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.