K
K
kirillleogky2020-05-03 11:09:05
JavaScript
kirillleogky, 2020-05-03 11:09:05

How to add nodes in a loop?

I add nodes to the DOM, but everything hangs from this code:

const contpre = document.createElement('div');
          contpre.className = 'contpre';

          for (let i = 0; i < 6; i + 1) {                                           
             contpre.append(document.createElement('label')); ------ вот эта часть кода из-за которой всё зависает
          }

tell me what is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2020-05-03
@kirillleogky

You have an infinite loop
i + 1 replace with i ++

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question