js点小图显示大图的切换功能代码
javascript点小图出大图 练习 by 阿会楠
body{
text-align:center;
margin:0 auto;
}
#imgList li img{
width:80px;
height:80px;
border:1px solid #cccccc;
}
ul li{
list-style:none;
float:left;
margin-left:20px;
cursor:pointer;
}
.rborder{
border:1px solid yellow;
}
var img = new Array();
img[0] = "/upload/20080918164412320.jpg";
img[1] = "/upload/20080918164413758.jpg";
img[2] = "/upload/20080918164414965.jpg";
function $(obj){
return document.getElementById(obj);
}
function $img(url){
return "";
}
function changeborder(obj){
for(var j = 0;j " + $img(img[i]) + "
";
}
if($("bImg").innerHTML == ""){
$("bImg").innerHTML = $img(img[0]);
$("imgList").getElementsByTagName("li")[0].getElementsByTagName("img")[0].style.borderColor = "red";
}
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]