Image self-replacement (image)

Source: Internet
Author: User

Js code:

I = 16/* the name of the image is a number, starting from 17 */
Function img ()
{
I ++
If (I = 23 ){
I = 17
}
Document. getElementById ('photo'). src = "images/" + I + ". jpg";/* note the format of the image */
SetTimeout ("img ()", 6000)
}

Function onClickNum (I)
{  

Document. getElementById ('photo '). src = "images/" + I + ". jpg"; note: images and HTML documents must be in the same root directory.

}

CSS code:  

# Shang {
Height: 405px;
Width: 100%;
}
# Num { 

Height: 65px;
Width: 980px;
Position: relative;
Top:-75px;
Left:-1px;
Background-color: #000;
Opacity: 0.6;
Filter: alpha (opacity = 50);/* implement transparency in IE */
-Moz-opacity: 0.5;/* transparent in Firefox */
}

# Num li {
Float: left;
Width: 125px;
Height: 49px;
Line-height: 58px;
List-style: none;
Margin-top: 6px;
Margin-right: 37px;
}
# Num li {
Display: block;/* block element */
Opacity: 0.7;
}
# Num li a: hover {
Border: 3px solid # 39F;/* border */
Opacity: 1;
}

HTML code:

<Div id = "shang">

<Div id = "num">
<Ul>
<Li> <a href = "#" onmouseover = "onClickNum (17)"> </a> </li>
<Li> <a href = "#" onmouseover = "onClickNum (18)"> </a> </li>
<Li> <a href = "#" onmouseover = "onClickNum (19)"> </a> </li>
<Li> <a href = "#" onmouseover = "onClickNum (20)"> </a> </li>
<Li> <a href = "#" onmouseover = "onClickNum (21)"> </a> </li>
<Li> <a href = "#" onmouseover = "onClickNum (22)"> </a> </li>
</Ul>
</Div>
</Div>

 

Image self-replacement (image)

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.