我已经设置了一个div窗体,它将显示一个帮助窗口,并且想要在onclick函数的右上角设置一个'X'关闭窗户。这个div位于我的HTML底部,就在end body标签之前,是正确的位置吗? 请注意,我想与显示器做到这一点:无标签,不显示()或隐藏() HTMLonclick功能关闭'帮助窗口'不工作
<div id="personalhelp"><p class="x"><a href="" onclick="close()">x</a></p>
<p class="help">Your personal information is needed to ensure we provide the most
relevant information and options for you. We will never sell your personal
information to third parties for any reason.</p>
<p class="help">Please fill in all required fields,
these are identified with an asterisk (*)</p>
</div>
功能(jQuery的)
function close() {
var getid = $(this).parent.attr('id');
console.log(getid);
$(getid).css("display", "none");
}
CSS
#personalhelp {
position: fixed;
right: 10%;
top: 10%;
max-width: 60%;
display: block;
background-color: #D3D3D3;
color: #000;
margin: 5px auto;
border: 2px solid #000;
display: block;
}
.x {
position: absolute;
right: 1%;
top:1%;
padding: 1px;
margin: 0 auto;
}
.help {
padding: 10px;
}
正如我在我的回答如下,更改回调提到名字从'close'某事物等,因为有浏览器的本地函数'close' –