我有这个jQuery刷新div,一旦它重新加载它删除div内的内容。有人可以帮我修复它,以便它可以刷新而不删除div中的内容吗?
$(document).ready(function() {
setInterval(function() {
var message = $('#show');
$('#show').html('');
}, 3000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="show" align="center">Refresh me</div>
答案 0 :(得分:0)
//I don't know why the heck you want to do these.
$(document).ready(function() {
var message = $('#show').text(); // retrieve the text bet^ the div
setInterval(function() {
$('#show').html(message); //Add the text bet^ the div
}, 3000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="show" align="center">Refresh me</div>