js点小图显示大图的切换功能代码 时间:2020-05-12 人气:0 javascript点小图出大图 练习 by 阿会楠 <script language="JavaScript" type="text/javascript"> 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.length;j++){ $("imgList").getElementsByTagName("li")[j].getElementsByTagName("img")[0].style.borderColor = "#cccccc"; } obj.style.borderColor= "red"; $("bImg").innerHTML = $img(obj.src); } window.onload = function(){ for(var i = 0;i < img.length;i++){ $("imgList").innerHTML += "" + $img(img[i]) + ""; } if($("bImg").innerHTML == ""){ $("bImg").innerHTML = $img(img[0]); $("imgList").getElementsByTagName("li")[0].getElementsByTagName("img")[0].style.borderColor = "red"; } } </script> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容