<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <title>微风软件开发</title> </head> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <body> <style type="text/css"> .imgViewDom { display: none; } .disnone{ background: rgba(255, 255, 255, 0.8); position: fixed; top: 0; left: 0; height: 100%; width: 100%; z-index: 99999999; overflow: auto; display: -webkit-box; -webkit-box-align: center; -webkit-box-pack: center; display: -moz-box; -moz-box-align: center; -moz-box-pack: center; display: -o-box; -o-box-align: center; -o-box-pack: center; display: -ms-box; -ms-box-align: center; -ms-box-pack: center; display: box; box-align: center; box-pack: center; } </style> <script> $(document).ready(function () { $(".imgViewDom2 img").click(function () { let imageSrc = $(this).attr("src"); let jQuery = $('.imgViewDom').attr("src"); console.log(imageSrc); if (jQuery==null){ $(".imgViewDom img").attr("src",imageSrc); $(".imgViewDom").attr("class","imgViewDom disnone"); } else { $(".imgViewDom").attr("class","imgViewDom"); } }); $(".imgViewDom img").click(function () { $(".imgViewDom").attr("class","imgViewDom"); }); }); </script> <div class="imgViewDom" style=""> <img src=""> </div> <div class="imgViewDom2"> <img src="https://www.qziu.cn/static/static/images/logo.png"> </div> </body> </html>