How to remove div completely in jQuery?

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

Was this solution helpful to you?

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:

Just Added Q & A:

Find solution

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.