林深见鹿 2017-04-14 02:58 采纳率: 0%
浏览 818

求大牛指点,如何用jquery动态创建模态层,并在页面上点击任意位置删除模态层

这是我的代码
<!DOCTYPE html>




Title
<br> *{<br> margin: 0;<br> padding: 0;<br> }<br> html,body{<br> width: 100%;<br> height: 100%;</p> <pre><code> } .box{ width: 100px; height: 100px; background: #7e7e7e; } .modal{ width: 100%; height: 100%; position: fixed; background: rgba(0,0,0,.3); top:0; left:0; } .on{ position: absolute; top: 50%; left: 50%; width: 250px; height: 150px; margin-left: -150px; margin-top: -100px; background: #FFFFFF; } p{ font-size: 18px; height: 50px; line-height: 50px; text-align:center; } button{ width: 100px; height: 50px; margin-left: 75px; margin-top: 10px; } &lt;/style&gt; </code></pre> <p></head><br> <body></p> <div class="box"></div> <!------------------------------------------------- <div class="modal"> <div class="on"> <p class="pic">图片不清晰</p> <button>关闭</button> </div> </div> ---------------------------------------------------> <p></body></p> <script> var $modal = $( '<div class="modal">'+ '<div class="on">'+ '<p class="pic">图片不清晰</p>'+ '<button>关闭</button>'+ '</div>'+ '</div>' ); var $hide = $('.modal'); $('.box').click( function(){ $('body').append($modal); }); </script> <p></html></p>
  • 写回答

1条回答 默认 最新

  • javageekcoder 2017-04-14 05:19
    关注

    对于这种可以利用jquery弹窗组件dialog,具体参考官方文档

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!