[英]hide a specific div from html ajax response
我没有尝试过Ajax。
我有这个html ajax响应,我想在ajax成功后隐藏第一个div“加载”
回应:
<div id="loading">
<label>..</label>
<div>...</div>
</div>
<div id="list">
...
...
</div>
我已经尝试了很多东西:
success: function (response) {
response.find('#loading').html().hide();
response.filter('#loading').hide();
response.find('#loading').hide();
}
但这不起作用。
通过其ID直接隐藏对象:
$('#loading').hide()
CSS:
.hidden { display: none; }
JS:
$.ajax({})
.done(function(data){
var html = $(data);
html.find('#loading').addClass('hidden');
$('document').append(html);
}
);
<div id="loading"> <p>Test</p> </div> <button onclick="test()"/> <script> function test() { document.getElementById("loading").style.display = "none"; } </script>
您必须在DOM中添加响应:
$(body).html(response);
那么你可以将div隐藏起来:
$("#loading").hide();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.