当我不再希望它们可见时,我一直在使用以下功能隐藏我的div
function hide(div) {
document.getElementById(div).style.display = 'none';
}
然而问题已经与div一起到了。
<div id="loading">
<img src="./img/loading.gif"/>
</div>
当我调用函数hide('loading')
时,只有部分图像被隐藏,并且它的切片被烧到页面上。考虑到这应该是一个小的加载图标,加盖到页面并不是我真正想要的,我该如何防止这种情况?
我在处理网络数据时使用加载图标,然后在接收和处理来自服务器(nodejs)的数据时隐藏它。
按要求提供css:
#loading {
position: fixed;
top: 50%;
left: 50%;
margin-top: -64px;
margin-left: -64px;
z-index: 999;
}
答案 0 :(得分:0)
<强> HTML 强>
<div id="one">
<img src="https://elora.aerb.gov.in/ELORA/images/loadingnew.gif">
</div>
<div id="two">
<img src="http://www.schultzlawoffice.com/img/loading/loading.gif">
</div>
<强>脚本强>
$(document).ready(function () {
$("div").on("click", function () {
var thisId = $(this)
hide(thisId);
});
});
function hide(thisId) {
$(thisId).hide();
}