【发布时间】:2013-11-22 13:50:51
【问题描述】:
我正在使用 jquery 来弹出我点击的图像。除了禁用 div 外,一切正常。谁能帮帮我?
如果我点击它在弹出窗口中加载的任何其他图像,会发生什么。
<!DOCTYPE html>
<html>
<head>
<title>Own</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("img").click(function(){
$("#page").css({ opacity: 0.2});
$('#page').prop('disabled',true);
$("#myModal").css({ opacity: 1});
var sr=$(this).attr('src');
$("#mimg").attr('src',sr);
$("#myModal").fadeIn("slow");
});
});
$(document).ready(function(){
$(".close").click(function(){
$("#myModal").fadeOut("slow");
$("#mimg").attr('src',"");
$("#page").css({ opacity: 1 });
});
});
</script>
<style>
.modal{
width:500px;
height:375px;
padding:5px;
border:1px solid #ccc;
opacity: 0;
-moz-box-shadow: 0 1px 3px #777;
-webkit-box-shadow: 0 1px 3px #777;
margin:40px auto;
}
.firefox {
position:fixed;
top:10%;
left:20%;
}
.chrome {
position:fixed;
top:10%;
left:60%;
}
.safari {
position:fixed;
top:50%;
left:20%;
}
.ie {
position:fixed;
top:50%;
left:60%;
}
</style>
</head>
<body>
<div id="page">
<img class="firefox" src="http://sheshtawy.files.wordpress.com/2010/05/extra-firefox.png" style="min-height:300px;height:300px;" alt="Responsive image">
<img class="chrome" src="http://3.bp.blogspot.com/-Dp427Q47tfw/UBkAh8v4LcI/AAAAAAAAAKA/sgSqilPx6Vw/s1600/Google_Chrome.jpg" style="min-height:300px;height:300px;" alt="Responsive image">
<img class="safari" src="http://www.tech2techsupport.com/image/safari.png" style="min-height:300px;height:300px;" alt="Responsive image">
<img class="ie" src="http://boredcentral.com/wp-content/uploads/2013/10/Chrome.jpeg" style="min-height:300px;height:300px;" alt="Responsive image">
</div>
<div class="modal" id="myModal">
<button type="button" class="close" style="position:fixed;top:5%;">×</button>
<img id="mimg" src="" style="min-height:300px;height:300px;" style="position:fixed;left:10%;"="Responsive image">
</div>
【问题讨论】:
-
div 不能被禁用。
-
@Govan,你最好的办法是在页面正文上覆盖
<div>。 -
如果你问的是灯箱逻辑,那么,只有2个div,一个用于背景,(黑色阴影与否),另一个用于显示内容,第一个div,整体覆盖页面,因此您无法单击其他项目。
-
检查这个例子@Govan jsfiddle.net/PyVjx/23如果你看到控制台你不能点击掩码后面的div
-
@Danko 我认为您必须将此作为答案发布,因为它是问题的解决方案
标签: javascript jquery html css