jQuery: How can I change the contents of a div during a time interval? say every 20mins i need to update the contents in the div.
-
I have 5 videos and i have a div which wraps the thumbnails of the video. We have given anchor for the thumbnail and the video pops up when the thumbnail is clicked. Now we need to change these thumbnails along with its respective urls each time with a time interval.
-
Answer:
You need two code pieces. 1- Jquery [code] setInterval(function(){ var offset = $('input#soffset').val(); if(offset == 15){ offset = 1; } $.ajax({ type : 'POST', url : 'includes/get-next.php', //dynamic file data : ({offset:offset,query:query,type:"tradeleads"}), //parameters success : function(msg){ $("ul#selling-slide").prepend(msg).delay(500).fadeIn('slow'); $("input#soffset").val(parseInt(offset)+1); } }); noffset++; }, 3000); [/code] 2- Dynamic code which gets thumbnails and returns. JS code will load the returned value of thumbnails and update div content. Above code working example: http://www.foodstrade.com (Trade Leads Slider)
Naveed Ramzan at Quora Visit the source
Other answers
Suppose Your code is something like this: [code] <div id="div_id"> <a href="http://link.com"> <img src="http://link.com/img/thumb1.jpg"> </a> <div> function changeDivContent(){ var $div = $('#div_id'); $('a',$div).attr('href','http://yourNewLink'); $('img',$div).attr('src','http://link.com/img/yourNewThumb.jpg'); } setInterval(changeDivContent, 5000); [/code] "setInterval(changeDivContent, 5000); " changeDivContent will be called every 5 secs/5000 milliseconds.
Dhruv Chaudhari
Related Q & A:
- On photobucket how can I change the background of a picture?Best solution by Yahoo! Answers
- How can I change my speakers in a Jeep Grand Cherokee limited?Best solution by Yahoo! Answers
- How can I change my avatar to a photo of me?Best solution by Yahoo! Answers
- How can I change my avatar to a picture?Best solution by Yahoo! Answers
- How can I tell if I am a baritone or a tenor?Best solution by quora.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.