我已經設置了一個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' –