+ 2
Js document.createElement _ help
I'm trying to create 30 elements, but it's not working, can you guys check this code for me please https://code.sololearn.com/WgQwP0o91ez8/?ref=app
4 Answers
+ 3
+ 1
Use a loop and then append in the loop
+ 1
Qudusayo can you please show me that in the code?
+ 1
There are few mistakes in your code.
First mistake, you should not use id #elem for creating repeated element, use className .elem instead.
Second mistake, var limit should be iterated using for operator to created 30 loops of create Element operation.
Third mistake, in css of .elem, it should not set with position: absolute; which eventually create 30 elements operlapping on the same location.
Fourth mistake, create function should be called upon onload event for all js pane code in Sololearn playground.
Last mistake, elm = document.getElementById('elem'); is unused.
https://code.sololearn.com/Wc8T9zIh1ia9/?ref=app