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?
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:
Comments
Post a Comment