Js image switch advertisement code

Source: Internet
Author: User
Tip: you can modify some code before running

<html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css">* {Margin: 0; padding: 0 ;}# gallery {width: 500px; background: orange; margin: 55px auto; position: relative ;}# gallery ul {list-style: none; width: 500px; height: 25px; background: url (images/bg.png) no-repeat; text-align: right; position: absolute; bottom: 0; left: 0 ;}# gallery li {float: right ;}# gallery # flower {display: block ;}# gallery li a {float: left; width: 40px; height: 25px; line-height: 25px; border-left: 1px solid # fff; font-size: 13px; text-align: center; text-decoration: none; color: #000 ;} # gallery li a: hover {background: # aeffdc;} # description {color: blue; position: absolute; top: 0; font-size: 13px ;}</style> </head> <body> <div id="gallery"> <ul id="list"> <li>Flowers</li> <li>Grass</li> <li>Leaf</li> <li>Sky</li> </ul> <p id="description">Image description!</p> </div> </body><script type="text/javascript">Var n = 0; function showpic (whichpic) {var s = whichpic. getAttribute ("href"); var flower = document. getElementById ("flower"); flower. setAttribute ("src", s); var text = whichpic. getAttribute ("title"); var description = document. getElementById ("description"); description. firstChild. nodeValue = text;} var _ = function (id) {return document. getElementById (id);} var l = _ ("list "). getElementsByTagName ("a"); for (var I = l. length-1; I> = 0; I --) {l [I]. onclick = function () {return false ;}} function auto () {showpic (l [n ++ % l. length]); setTimeout (auto, 500);} auto ();</script></html>
Tip: you can modify some code before running

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.