javascript - how to change multiple div every 5 seconds -


this question has answer here:

i tried update posts every 5 seconds, time updated, how many users commented , how many likes. code tried far text1

<div id='poster' class='1'> <input type='hidden' value='1' id='post_id'> text1 </div>  <div id='poster' class='2'> <input type='hidden' value='2' id='post_id'> text2 </div>  <div id='poster' class='3'> <input type='hidden' value='3' id='post_id'> text3 </div>  <div id='poster' class='4'> <input type='hidden' value='4' id='post_id'> text4 </div> 

in body there onload='refresh()' here what's in java.js:

function refresh(){ var post_id = $("#post_id").val(); settimeout(refresh_post(post_id),5000); }  function refresh_post(post_id){     $("."+post_id+"").load("post.php?post_id="+post_id); } 

but updates first div rest remains same

use setinterval if want update post @ every 5 second continuosly.

setinterval(function(){  $('input:hidden').each(function() {  var post_id = $(this).attr('id');  refresh_post(post_id) }); }, 5000); 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -