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 实现点击缩略图显示大图,布布扣,bubuko.com

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

上一篇:避免常见的6种HTML5错误用法


下一篇:ADO.NET命名规范