jQuery hide() on按钮不起作用,然后div的show()没有出现。哪里出了问题?
但是,当互联网关闭时,它工作得很好。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 display:none和display:block相同的方法,但不起作用。
发布于 2016-05-24 04:34:28
确保在进行小提琴操作时,导入了jQuery库。当display:none
为ready
时,您可以在jQuery中使用.hide()
函数,而不是给div一个document
。这是小提琴-> https://jsfiddle.net/rr1gwyr7/2/
https://stackoverflow.com/questions/37395363
复制相似问题