How to create 10 divs in which their number will be written?
-
It is necessary that inside each diva it is written what it is by numberJavaScript Anonymous, Jul 3, 2020
-
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 -
for (var i = 0; i < 10; i++) {
var newDiv = document.createElement("div");
newDiv.innerHTML = i;
document.body.appendChild(newDiv);
}Eloise Petty
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!