渐入弹窗,背景变色不可点击。查看效果:http://runjs.cn/detail/t08gmoij
<!doctype html> <html> <head> <meta charset="utf-8"> <title>popup</title> <script type="text/javascript" src="jquery-2.1.3.min.js"></script> </head> <style type="text/css"> #popup{ position: absolute;display:none; z-index:3000; background-color:#FFF; left: 601px; top: 217px; height: 150px; width: 217px;line-height:94px;text-align:center; border: 1px solid #03F; } #embedding{ position: absolute; background-color: #36F; top: 94px;height:56px; width:217px;line-height:56px;text-align:center; } a{ text-decoration:none; font-family:"微软雅黑"; font-size:18px; color:#FFF; } </style> <script type="text/javascript"> $(function(){ var url = null; $(document).on('click','button',function(){ var text = $(this).text(); switch(text){ case 'OSChina':url = 'http://www.oschina.net/';break; case 'baidu':url = 'http://www.baidu.com/';break; case 'CSDN':url = 'http://bbs.csdn.net/home';break; } $('#text').text('是否确定前往 '+text+' ?'); $('#loadingDiv').css('display','block'); $('#popup').slideDown(); }); $(document).on('click','a',function(){ if($(this).text()=='确定'){ location.href=url; }else{ $('#loadingDiv').css('display','none'); $('#popup').slideUp(); } }); }); </script> <body> <div id="loadingDiv"></div> <div id="popup"> <span id="text"></span> <div id="embedding"> <a href="javascript:void(0)">确定</a> <a href="javascript:void(0)">取消</a> </div> </div> <button >OSChina</button> <button >baidu</button> <button >CSDN</button> </body> </html>
以上所述就是本文的全部内容了,希望大家能够喜欢。
【jQuery+html5实现div弹出层并遮罩背景】相关文章:
★ javascript实现点击按钮弹出一个可关闭层窗口同时网页背景变灰的方法
★ jQuery插件pagewalkthrough实现引导页效果