The text in the JavaScript settings Div scrolls to achieve the scrolling effect.

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>Title</title>6 </Head>7 <Body>8 <DivID= "I1"style= "width:400px;9 height:300px;Ten Position:absolute; One left:50%; A top:50%; - margin-left: -200px; - margin-top: -150px; ">welcome Zinming to visit our guide the </Div> - <Script> -     functionf () { -         //get the corresponding div,document according to the ID meaning is to go to the entire HTML document to find, getElementById is based on the ID +         varTag=document.getElementById ('I1') -         //get the text in the Div, note that the InnerText method has no parentheses +         varcontent=Tag.innertext A         //get the first text of this string at         varZ=Content.charat (0) -         //get this text in addition to the first word, with substring give it a starting position -         varL=content.substring (1, Content.length) -         //Put the first character on the last one and stitch it up. -         varnew_content=L+Z -         //Replace the text in the div with the newly generated new_content in Tag.innertext=new_content -     } to     //SetInterval is a timer, the first parameter is the content to be executed, the second parameter is the execution interval, in milliseconds + SetInterval ('f ()', -) - </Script> the  * </Body> $ </HTML>

The text in the JavaScript settings Div scrolls to achieve the scrolling effect.

Related Article

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.