<div class="form-control" id="sign_in" style="display:none">
<input type="text" class="form-control" placeholder="Username">
<input type="text" class="form-control" placeholder="password">
<input type="button" class="btn btn-primary" value="sign in">
<input type="button" class="btn btn-success" value="cancle">
</div>
<script>
function signIn() {
addBg();
var alert_sign_in = document.getElementById("sign_in");
alert_sign_in.style.display = "block";
alert_sign_in.style.position = "absolute";
alert_sign_in.style.top = "50%";
alert_sign_in.style.left = "50%";
alert_sign_in.style.marginTop = "-75px";
alert_sign_in.style.marginLeft = "-150px";
alert_sign_in.style.width = "500px";
alert_sign_in.style.height = "700px";
alert_sign_in.style.zIndex = "501";
var mybg = document.createElement("div");
mybg.setAttribute("id","mybg");
mybg.style.background = "#000";
mybg.style.width = "100%";
mybg.style.height = "100%";
mybg.style.position = "absolute";
mybg.style.top = "0";
mybg.style.left = "0";
mybg.style.zIndex = "500";
mybg.style.opacity = "0.3";
mybg.style.filter = "alpha(opacity=30)";
document.body.appendChild(mybg);
document.body.style.overflow = "hidden";
}
</script>
這個是一個彈出式的登錄功能,先有個遮罩層,然後彈出一個form供用戶輸入信息,請問這個這個form如何關閉?就是用戶取消登錄的時候,遮罩層自動取消,然後form自動關閉。
彈出式的登錄功能是這樣寫的嗎?有沒有其他的寫法,謝謝。
用JQUERY把form和遮罩層的div隱藏即可,或者移除
隱藏代碼
$("form的ID").hide();
$("div的ID").hide();
移除代碼
$("form的ID").remove();
$("div的ID").remove();