有任何想法吗?
setInterval(function() { $.post( 'json.PHP',function(data){ $('#tweetBox').append('<p>' + data + '</p>'); var list = $('#tweetBox p').length; if (list > 3){ $('#tweetBox p:last-child').remove(); } } ); },5000);
The last item doesn’t get removed and no new items get appended.
这表示新项目会被追加,但会立即删除.您想要撤销订单:
var list = $('#tweetBox p').length; if (list === 3){ $('#tweetBox p:last-child').remove(); } $('#tweetBox').append('<p>' + data + '</p>');