JS 实现点击缩略图显示大图

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <title></title>
    <style type="text/css">
        #imgFrame{ position:absolute; top:40%; left:40%; z-index:1000; display:none;}
    </style>
</head>
<body>
    <div>
        <ul>
            <li>
                <img src="小图路径1" original="原图路径1" onclick="showOriginal(this)" />
            </li>
            <li>
                <img src="小图路径2" original="原图路径2" onclick="showOriginal(this)" />
            </li>
            <li>
                <img src="小图路径3" original="原图路径3" onclick="showOriginal(this)" />
            </li>
            <li>
                <img src="小图路径4" original="原图路径4" onclick="showOriginal(this)" />
            </li>
        </ul>
    </div>
     
    <div id="imgFrame">
        <div><a href="javascript:close();">关闭</a></div>
        <div id="imgbox"></div>
    </div>
     
    <script type="text/javascript">
        function showOriginal(img) {
            document.getElementById("imgFrame").style.display = "block";
            document.getElementById("imgbox").innerHTML = "<img src=‘" + img.getAttribute("original") + "‘ />";
        }
        function close() {
            document.getElementById("imgFrame").style.display = "none";
        }
    </script>
 
</body>
</html>

 

JS 实现点击缩略图显示大图,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。