Jquery 加载时未隐藏的图像
当页面加载图像时,假设在验证url参数之前隐藏,并根据参数值显示正确的图像。这里的问题是,图像根本不隐藏,特别是在快照代码中,但当相同的代码在不同的项目中使用时,它可以工作。这里有什么魔力 剧本Jquery 加载时未隐藏的图像,jquery,css,Jquery,Css,当页面加载图像时,假设在验证url参数之前隐藏,并根据参数值显示正确的图像。这里的问题是,图像根本不隐藏,特别是在快照代码中,但当相同的代码在不同的项目中使用时,它可以工作。这里有什么魔力 剧本 $(function () { $('#graphic img').hide(); $.ajax({ url: 'ServerData.aspx', dataType: 'text',
$(function () {
$('#graphic img').hide();
$.ajax({
url: 'ServerData.aspx',
dataType: 'text',
type: "GET",
success: function (data) {
var result = $.trim(data);
if (result == 2) {
$("#gate2").show();
} else if (result == 3) {
$("#gate2").show();
} else if (result == 4) {
$("#gate3").show();
} else {
}
}
});
});
Div
资料
1.
删除此
$('#graphic img').hide();
把这些换成
<img id="gate1" src="img/Fully Close Red.png" style="display:none; left: 321px; top: 294px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate2" src="img/Fully Open Green.png" style="display:none; left: 333px; top: 300px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate3" src="img/Half Open Green.png" style="display:none; left: 316px; top: 299px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate4" src="img/Half Open Red.png" style="display:none; left: 317px; top: 296px; z-index: 35; width: 154px; height: 92px; " />
确保图像在渲染时隐藏是否在代码中导入了jQuery?请尝试更改$(“#graphic img”).hide();到$('#graphic').hide();。如何包含jQuery?异步还是同步?如果是同步,是在这些图像之前还是之后包含它?这就是jQuery包含的方式
<img id="gate1" src="img/Fully Close Red.png" style="display:none; left: 321px; top: 294px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate2" src="img/Fully Open Green.png" style="display:none; left: 333px; top: 300px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate3" src="img/Half Open Green.png" style="display:none; left: 316px; top: 299px; z-index: 35; width: 154px; height: 92px; " />
<img id="gate4" src="img/Half Open Red.png" style="display:none; left: 317px; top: 296px; z-index: 35; width: 154px; height: 92px; " />