I have this code that works fine. The new part of the data goes fine, but when the number p reaches 3, nothing happens. The last item is not deleted, and new items are not added.
Any ideas?
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);
source share