S
S
svilkov872018-03-19 22:23:15
JavaScript
svilkov87, 2018-03-19 22:23:15

How to create more than one element in pure js?

Hello everyone and I have changed the content of the question.
One element is created like this, for example: Given: How to create elements in an amount that matches the value of count, i.e. create 4 spans?
var span = document.createElement('span');
var count = 4;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
svilkov87, 2018-03-19
@svilkov87

Solved the issue like this:

var i = 4;
for (i; i > 0; i--){
    var div = document.createElement('span'); 
    div.className = "span";
    div.innerHTML = 'this is span';
    document.body.appendChild(div);
}

S
Sergey Epifanov, 2018-03-19
@kacheleff

Answer on StackOverflow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question