Create seamless scrolling News with jquery step-by-step

Source: Internet
Author: User

First of all, we have this HTML code, very concise, as follows:

1 <div id= "tag" >
2 <ul>
3 <li> You say I am a good person, I am a good person </li>
4 <li> haha, I really don't know what to say </li>
5 <li> Life is supposed to be plain </li>
6 <li> work like a school </li>
7 </ul>
8 </div>

And then all we have to do is make it roll seamlessly.

First we introduce the content into jquery and get to the first element in the LI element list

Here we are using the Clone () method to get and then display its contents:

1 <script type= "Text/javascript" src= "Jquery-1.3.2.min.js" ></script>
2 <script type= "Text/javascript" >
3 $ (document). Ready (function () {
4 $ (' #tag li '). EQ (0). Click (function () {
5 alert (this). Clone (). text ()); The result is "are you saying I'm a good person, I'm a good person?" represents the text content of the first LI element
6});
7 </script>

Then there is the list of all the LI elements, and here we use the parent () method to get a list of all the LI elements:

Code

The next thing to do is append the contents of the first LI element you get to the contents of all LI elements list:

Code

Received above, continue to do is to let the first LI element to hide, as follows:

Code

Finally using SetInterval (' scroll_news () ', 1000);

The final complete code is as follows:

Code

In fact, a step-by-step, will eventually get results

Create seamless scrolling News with jquery step-by-step

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.