How to create 10 divs in which their number will be written?

  • 0
    It is necessary that inside each diva it is written what it is by number
    JavaScript Anonymous, Jul 3, 2020

  • 2 Answers
  • 0
    Damn ...

    document.body.innerHTML = "<div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div><div>7</div><div>8</div><div>9</div><div>10</div>";




    Anecdote on the topic:

    Holmes and Watson are flying in a hot air balloon. And they sleep in flight. Wake up

    over some unfamiliar land, they see - below some horseradish grazing cows.

    They went down and asked the guy:

    - Tell me, sir, where are we?

    - Hot air balloon.

    - Thanks sir! - and fly up. Holmes says thoughtfully:

    - Watson, it was a programmer.

    - Holmes, where did you get the idea that he is a programmer?

    - It's elementary! First, its

    the answer was absolutely accurate. And secondly, it is absolutely useless!
    Anonymous

  • 0
    for (var i = 0; i < 10; i++) {
    var newDiv = document.createElement("div");
    newDiv.innerHTML = i;
    document.body.appendChild(newDiv);
    }
    Eloise Petty

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!