<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style > body{text-align:center}
div{align:center} </style>
<title>无标题文档</title>
</head> <body> <select id="option" onchange="change()">
<option value="1">图片1</option>
<option value="2">图片2</option>
<option value="3">图片3</option>
<option value="4">图片4</option> </select>
<br /><br /><br /><br />
<div class="images" width="790px" >
<div align="center">
<img id="1"width="790px" height="340px" src="../../课堂练习/js03/59a7a48aN7a42d3fe.jpg" style="display:block"/>
<img id="2"width="790px" height="340px" src="../../课堂练习/js03/59cc929fNaebef801.jpg" style="display:none"/>
<img id="3"width="790px" height="340px" src="../../课堂练习/js03/59ccc986Nbf17e33e.jpg" style="display:none"/>
<img id="4"width="790px" height="340px"src="../../课堂练习/js03/59ccec77N64688a8d.jpg" style="display:none"/>
</div>
</div>
<script>
function change(){
var opt=document.getElementById("option");
if(opt.value=="1"){
var images=document.getElementsByTagName("img");
for(var i=0;i<images.length;i++){
if(images[i].id==1){
images[i].style.display="block";
}else{
images[i].style.display="none";
}
}
}
if(opt.value=="2"){
var images=document.getElementsByTagName("img");
for(var i=0;i<images.length;i++){
if(images[i].id==2){
images[i].style.display="block";
}else{
images[i].style.display="none";
}
}
}
if(opt.value=="3"){
var images=document.getElementsByTagName("img");
for(var i=0;i<images.length;i++){
if(images[i].id==3){
images[i].style.display="block";
}else{
images[i].style.display="none";
}
}
}
if(opt.value=="4"){
var images=document.getElementsByTagName("img");
for(var i=0;i<images.length;i++){
if(images[i].id==4){
images[i].style.display="block";
}else{
images[i].style.display="none";
}
}
} } </script> </body>
</html>
05-07 15:50