此頁面有圖像,這些圖像必須在加載時間隱藏,頁面從另一個aspx頁面接收參數值(不點擊任何按鈕)後,圖像顯示基於一個參數值。此代碼可以成功接收數據,但如何使用參數值隱藏和顯示圖像?隱藏圖像在加載時間和顯示基於一個url參數值
HTML:
<input type="button" id="mybutton" />
<script>
$('#mybutton').click(function() {
$.ajax({
url: 'About.aspx',
dataType: 'text',
type: "GET",
success: function(data)
{
var result = $.trim(data);
if (result = 2) {
$("image1").show();
} else {
if (result = 3) {
$("image2").show();
}
}
}
});
});
</script>
<div id="graphic">
<img id="gate1" src="Img/Fully Close Green.png" />
<img id="gate2" src="Img/Fully Close Red.png" />
</div>
仍然顯示所有圖像?如何解決這個問題? –
@Algiri瀏覽器控制檯中的任何錯誤? –
顯示沒有錯誤。 –