0
jQuery hide()on button not working,then then show()of div does not appear。哪裏出錯了?jQuery隱藏()和顯示()在div不工作
但是,它在互聯網關閉時工作正常。 jQuery庫在本地託管。
#loading {
background: url('/img/loading.gif') no-repeat;
width: 30px;
height: 30px;
}
<button id="submit" type="submit" disabled>Submit</button>
<div id="loading" style="display:none"></div>
$(document).ready(function() {
document.getElementById('submit').disabled = false; // enable the button
$('#submit').click(function() {
$(this).removeClass("active"); // either $(this) or $('submit')
$(this).hide(); // either $(this) or $('submit')
$('#loading').show();
});
});
就像前面說的,上面的代碼工作正常,當互聯網關閉。此外,與JS顯示:無和顯示:塊,嘗試相同的,不工作。
https://jsfiddle.net/945ovayj/1/
你怎麼能點擊'禁用'按鈕? – Satpal
很好的@Satpal,我忘記提及了。在執行上述代碼之前,當用戶在輸入框中輸入所需的項目時,它被啓用。 document.getElementById('submit')。disabled = false; – D09r
'disabled'屬性放在一邊,這不起作用,因爲點擊提交按鈕會導致頁面被卸載,因爲正在請求新頁面。這意味着所有UI更新都會停止。 –