想大家都做過遮罩層這種常見的功能,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; <myop; 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>mybggg .style.filter = "Alpha(opacity=30)"; <BR>document.body.appendChild(mybg); <BR><br>//document.body.style.overflow = "hidden"; <br>} <BR> 頁碼: 複製程式碼 程式碼如下