gpt4 book ai didi

javascript - 正文溢出:visible on pop up close

转载 作者:行者123 更新时间:2023-12-02 17:08:11 24 4
gpt4 key购买 nike

这是显示弹出联系表单的 JS 函数:

function check_empty(){
if(document.getElementById('name').value == ""
|| document.getElementById('email').value == ""
||document.getElementById('msg').value == "" ){
alert ("Fill All Fields !");
}
else {
document.getElementById('form').submit();
alert ("Form submitted successfully...");
}
}

//function to display Popup
function div_show(){
document.getElementById('abc').style.display = "block";
document.body.style.overflow = "hidden";
}

//function to check target element
function check(e){
var target = (e && e.target) || (event && event.srcElement);

var obj = document.getElementById('abc');
var obj2 = document.getElementById('popup');
checkParent(target)?obj.style.display='none':null;
target==obj2?obj.style.display='block':null;
}


//function to check parent node and return result accordingly
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('abc'))
{
return false
}
else if(t==document.getElementById('close'))
{
return true

}
t=t.parentNode

}
return true

}

当弹出窗口加载时document.body.style.overflow = "hidden";停用溢出。现在我想设置document.body.style.overflow = "visible";单击关闭按钮(当我关闭弹出窗口时)。关闭按钮在 html 中定义为:<img src="images/3.png" id="close"/>是否可以 ?这是完整的 html 表单:

 <form action="#" method="post" id="form" >
<img src="images/3.png" id="close"/>
<h2>Contact Us</h2><hr/>
<input type="text" name="name" id="name" placeholder="Name"/>

<input type="text" name="email" id="email" placeholder="Email"/>

<textarea name="message" placeholder="Message" id="msg"></textarea>

<a id="submit" href="javascript: check_empty()">Send</a>
</form>

最佳答案

HTML

<img src="images/3.png" id="close" onclick="myFunction()">

JS

function myFunction() {
document.getElementsByTagName("body")[0].style.overflow = "visible";
}

关于javascript - 正文溢出:visible on pop up close,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25068719/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com