本人Js菜鸟,最近要用到遮罩层
从网上找到一个大神的代码,备份一下
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(function () { $("#layer") .height($(document).height()) .width($(document).width()).hide(); $("#btn").click(function () { $("#layer").show(); }); $("#layer").click(function () { $(this).hide(); }); }); </script> <style type="text/css"> #layer{ position: absolute;top: 0;left: 0;opacity: 0.6; background-color:#000000; z-index:999;} </style> </head> <body> <div id="layer"></div> <input type="button" id="btn" /> </body> </html>