javascript - (Solved) Repeat block of text for each DIV instance -


i trying text showup after each post in tumblr theme, , javascript works in jsfiddle, not when include theme. missing something?

http://jsfiddle.net/kp3uw/70/

html

<div id="wrapper">     <div class="post">         <div class="stat-wrap"></div>     </div>     <div class="post">         <div class="stat-wrap"></div>     </div>     <div class="post">         <div class="stat-wrap"></div>     </div>     <div class="post">         <div class="stat-wrap"></div>     </div>     <div class="post">         <div class="stat-wrap"></div>     </div>     <div id="counter"></div> </div> 

javscript

  /*global */    function statwrap() {       var count;       var counter;       var bob;       count = document.getelementsbytagname('div').length;       counter = document.getelementbyid('counter').innerhtml = count;       bob = document.getelementsbyclassname('stat-wrap');       var i;       (i = 0; < counter; i++) {           bob[i].innerhtml = "jkfdgdff14";       }   }   window.onload = statwrap(); 

here's tumblr theme have pasted javascript btw. (http://lgbtvee.tumblr.com/) i've tried both above </head> , </body> ending tags didn't work either place.

i think have made wayy complicated.

try using jquery , using append() function:

$( ".stat-wrap" ).append( "<p>test</p>" ); 

example:

http://jsfiddle.net/kp3uw/74/


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -