js如何实现点击图片弹出窗口并放大这张图片,最好弹出的窗口不是另一个页面
2个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#divid {
position:fixed;
z-index:2000;
left:50%;
top:50%;
transform:translate(-50%,-50%);
}
#imgid {
width:1000px;
height:500px;
}
</style>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
<script >
function myFunction(){
var src=$("#imgip").attr("src")
$("#imgid").attr("src",src)
$("#divid").css("display","block")
}
function myFunc(){
$("#divid").css("display","none")
}
</script>
</head>
<body>
<img id="imgip" onclick="myFunction()" src=""/>
<div style="display:none;" id="divid" >
<img onclick="myFunc()"袭皮 src="" id="imgid" />
</div>
</body>
</拿禅清html>消前
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#divid {
position:fixed;
z-index:2000;
left:50%;
top:50%;
transform:translate(-50%,-50%);
}
#imgid {
width:1000px;
height:500px;
}
</style>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
<script >
function myFunction(){
var src=$("#imgip").attr("src")
$("#imgid").attr("src",src)
$("#divid").css("display","block")
}
function myFunc(){
$("#divid").css("display","none")
}
</script>
</head>
<body>
<img id="imgip" onclick="myFunction()" src=""/>
<div style="display:none;" id="divid" >
<img onclick="myFunc()"袭皮 src="" id="imgid" />
</div>
</body>
</拿禅清html>消前
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询