<body>
<div class="deom">
<div id="hd"><img src="img/05.jpg" width="500px" height="300px"></div>
<div id="hx">
<ul>
<li><img src="images/02.jpg"></li>
<li><img src="images/01.jpg"></li>
<li><img src="images/05.jpg"></li>
<li><img src="images/04.jpg"></li>
<li><img src="images/03.jpg"></li>
</ul>
</div>
</div>
</body>
<script type="text/javascript">
window.onload=function(){
var oBd = document.getElementById("hd");
var oSd = document.getElementById("hx");
var oImg = oBd.getElementsByTagName("img")[0];
var aImg = oSd.getElementsByTagName("img");
//alert(Si);
for(var i=0;i<aImg.length;i++){
aImg[i].onclick=function(){
oImg.src=this.src;
}
}
}
</script>
为什么获取ul li里面图片的时候要现先获取外面的DIV(oBd和oSd),然后在用oBd.get...呢?直接document.getEl...("img")为什么不行?
求解释,谢谢!
开心就好OO