Js document.createElement _ help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

8th Sep 2019, 10:09 PM
Ginfio
Ginfio - avatar
4 Answers
8th Sep 2019, 10:45 PM
Qudusayo
Qudusayo - avatar
+ 1
Use a loop and then append in the loop
8th Sep 2019, 10:24 PM
Qudusayo
Qudusayo - avatar
+ 1
Qudusayo can you please show me that in the code?
8th Sep 2019, 10:33 PM
Ginfio
Ginfio - avatar
+ 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
9th Sep 2019, 4:09 AM
Calviղ
Calviղ - avatar