Answer the question
In order to leave comments, you need to log in
How to insert elements from an array into html tags?
There are elements in the array [1, 2, 3]. And there are tags. How to make the elements from the array inserted into these tags.
The entry needs to look like:<h1> 1 </h1> <h1>2 </h1> <h1>3 </h1>
Answer the question
In order to leave comments, you need to log in
var arr = [1, 2, 3];
var toHTML = "<h1>" + arr.join(" </h1><h1>") + "</h1>";
alert(toHTML);
arr.map(function(h){
return "<h1>" + h + " </h1>";
}).join("");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question