javascript - Add to element as divs -



javascript - Add to element as divs -

okay, here's code: html:

<h2>header</h2> <div id="results1" class="results"> <h1>results 1</h1> </div>

js:

(function() { var results = document.getelementbyid('results1'); var drink = [ 'rum', 'vodka', 'whiskey', 'beer' ]; })();

i need add together drinks results element divs.

just simple for loop iterate on array, , append each item results div.

(var = 0 ; < fruit.length; i++) { results.innerhtml += "<div>" + fruit[i] + "</div>"; };

jsfiddle demo

javascript jquery html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -