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更新都会停止。 –