javascript - Add class when Load content from external source -


given script load data specific div of external source on click. trying add div class when loading content image , text. mean when contents loads new classes auto added <div class="images"> img</div> , <div class="summery"> text text text</div>

html:

<button class='btn'/> <div id="load-here"></div> <!-- load here -->  </body> 

script:

$(function() {     var page = null;     var counter = 0;      function getnext() {     // grab next element array of date-outer divs , copy .content div         if (counter >= page.length)             return;         var elm = $(page[counter]).clone();         elm.find('script').remove(); // remove script tags in div         elm.appendto('#load-here');         counter++;     }      $('button.btn').click(function(e) {         if (page === null) {             page = false; // prevents request being made twice             $.get('http://test-html-site.blogspot.com/search/label/', function(data) {                 page = $(data).find('article.post.hentry');                 getnext();             });         } else if (page !== false) {             getnext();         }     }); }); 

html structure of external site: given script load .date-outer per click. means load data form external site/link on click.

<body> <div class="blog-posts hfeed">   <div class="date-outer"> contecnt 1: img, text </div>  <div class="date-outer"> contecnt 2: img, text </div>  <div class="date-outer"> contecnt 3: img, text </div>  </div> </body> 

my question when data loading, want add custom class image , text using given script. example site.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -