javascript - Div 未禁用

标签 javascript jquery html css

我正在使用 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%;">&times;</button>
    <img id="mimg" src="" style="min-height:300px;height:300px;" style="position:fixed;left:10%;"="Responsive image">
</div>

最佳答案

好吧,在对注释进行一些修改后,解决方案是将内容与 div 重叠。此掩码禁用对后面元素的访问,并允许您控制前面的其他信息:

演示在这里 http://jsfiddle.net/PyVjx/23/

一些提示:

  • 重要的是使基于 position:fixedz-index 的掩码高于内容,并以 display:none 开头code> 使其隐藏,这是 css:

    .mask {
     display:none;
     width:100%;
     height:100%;
     position:fixed;
     top:0;
     left:0;
     z-index:10;
    }
    
  • 其次, mask 上的内容还需要 positionz-index 在这种情况下高于 mask 。

    .overmask {
       display:none;
       position:absolute;
       z-index:15;
    }
    

然后你可以使用 Jquery 显示和隐藏它:

$('.launcher').click(function () {
    $('.mask').fadeIn();
    $('.overmask').show();
});

关于javascript - Div 未禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20146500/

相关文章:

javascript - 是否有任何 jquery 插件可以在 HTML 页面中保留通用的页眉和页脚?

javascript - 如何从组件 <video></video> 获取帧

javascript - Android 浏览器中不允许使用字母或除数字 (0-9) 或小数之外的其他符号

无法使用带点的相对路径加载 Javascript 文件

javascript - <a> svg 周围的链接行为异常

javascript - 只是想确保我做的事情是对的

jQuery Sum 表 td 并且只允许总计 100

html - 如何创建 HTML 格式的电子邮件

jQuery UI 对话框 : how to add tabs to content area?

Jquery Mobile 固定 header 。将标题保持在顶部