javascript - How to refresh div with jquery, without duplicating -


i'm using code refresh div every 10 seconds:

<script type="text/javascript"> setinterval(function(){         $('#feed').load('forum.php #feed').fadein("slow"); }, 10000); </script> 

works great, except first load (after 10 seconds) makes duplicate of div, it's 1 sitting atop other. after that, div refreshes every 10 seconds, without making more duplicates.

any ideas what's wrong code? div is:

<div id="feed">... stuff ... </div> 

thanks!

from jquery docs:

when method executes, retrieves content of ajax/test.html, jquery parses returned document find element id of container. this element, along contents, inserted element id of result, , rest of retrieved document discarded.

so inserting same element page multiple times.

try changing selector

$('#feed').load('forum.php #feed>*').fadein("slow"); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -