3.实现有一个图片和五个数字链接,单击不同的数字链接显示不同的图片。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>图片轮换</title>
<link rel="stylesheet" href="css/scroll.css">
</head>
<body>
<div class="scroll">
<div id="num">
<a href="#" onmouseover="one()">1</a>
<a href="#" onmouseover="two()">2</a>
<a href="#" onmouseover="three()">3</a>
<a href="#" onmouseover="four()">4</a>
<a href="#" onmouseover="fifth()">5</a>
</div>
<img src="images/1.gif" alt="图片" id="photo"/>
</div>
<script>
var doc = document.getElementById("photo");
function one() {
doc.setAttribute("src","images/1.gif")
}
function two() {
doc.setAttribute("src","images/2.gif")
}
function three() {
doc.setAttribute("src","images/3.jpg")
}
function four() {
doc.setAttribute("src","images/4.jpg")
}
function fifth() {
doc.setAttribute("src","images/5.gif")
}
</script>
</body>
</html>