Image switching is very popular, and text switching is also very practical. In addition, CSS can be used with JavaScript to avoid writing text into JavaScript code when pure JavaScript is implemented, which is inconvenient to modify. This is convenient, simple, practical, and compatible. you can think of it as a normal CSS list, with only two or three lines of code added to complete the switching effect.
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN"> <HTML> <HEAD> <TITLE> regular text change Code </TITLE> <style type = "text/css"> # newslist {background: # f8f8f8; border: 1px solid silver; padding: 1px; height: 20px; line-height: 20px; width: 288px;} # contain {font-size: 12px; overflow: hidden; list-style: none; width: 288px; height: 20px; margin: 0px; padding: 0 ;}# contain li {height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden ;} </style> </HEAD> <BODY> <p id = "newslist"> <ul id = "contain"> <li> Baidu, the world's largest Chinese search engine </li> <li> CSDN, the most popular it community in China </li> <li> SCRIPT house </li> <li> player </li> </ul> </p> <script language =" javaScript "> function xx () {var container = document. getElementById ("contain"); container. appendChild (container. firstChild);} setInterval ("xx ()", 2000); SCRIPT </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]