想大家都做过遮罩层这种常见的功能,css或jquery实现,实现方式多样化,这里http://我介绍我在项目中实现的方式,全屏遮罩,部分区域可操作,非常实用。 效果如下图: js 实现部分: 复制代码 代码如下: <BR>var myAlert = document.getElementById("alert"); <BR>var reg = document.getElementById("content").getElementsByTagName("a")[0]; <BR>reg.onclick = function() { <BR>myAlert.style.background = "#e2ecf5"; <BR>myAlert.style.zIndex = "501"; <BR>myAlert.style.position = "absolute"; <br><br>var signSpan = document.getElementById("signSpanId"); <BR>myAlert.style.top = signSpan.offsetTop; <BR>myAlert.style.left = signSpan.offsetLeft; <br><br>mybg = document.createElement("div"); <BR>mybg.setAttribute("id", "mybg"); <BR>mybg.style.background = "#000"; <BR>mybg.style.width = "100%"; <BR>mybg.style.height = "100%"; <BR>mybg.style.position = "absolute"; <BR>mybg.style.top = "0"; <BR>mybg.style.left = "0"; <BR>mybg.style.zIndex = "500"; <BR>mybg.style.opacity = "0.3"; <BR>mybg.style.filter = "Alpha(opacity=30)"; <BR>document.body.appendChild(mybg); <br><br>//document.body.style.overflow = "hidden"; <BR>} <BR> 页面代码: 复制代码 代码如下: