+ 1

I want to do list item with ordered list. I do this. I have error and i haven't output. Thanks you.

Ordered list item. https://code.sololearn.com/W5mLJ6XQOBxU/?ref=app

15th Jan 2021, 12:28 PM
Malick Diagne
Malick Diagne - avatar
7 Answers
+ 1
Errors were quite self explanatory ,so it would be better to understand how dom works and how objects hold a property or a function and what they don't hold(like you could have looped over object to see why you are getting error) to avoid confusion in future. Maybe you needed this ? var myol = document.getElementById ("parent"); var li= document.createElement ("li"); myol.appendChild(li); li.innerHTML="Glucose"; document.body.appendChild (myol );
15th Jan 2021, 12:32 PM
Abhay
Abhay - avatar
0
And i do it. It is one child of parent. How Can i do more child. Thanks you.
15th Jan 2021, 12:52 PM
Malick Diagne
Malick Diagne - avatar
0
is it list item ?
15th Jan 2021, 12:54 PM
Malick Diagne
Malick Diagne - avatar
0
Malick Diagne li is a ordered list (ol) item. To create more child list for the ordered list , use document.createElement for every new element . For example array=["something","something"] for(let i=0;i<2; i++){ var li=document.createElement("li"); li.innerHTML=array[i]; ol.appendChild(li); }
15th Jan 2021, 2:16 PM
Abhay
Abhay - avatar
0
How about with HTML only? <body> <ol> <li>Glucose</li> <li>pommade</li> <li>bande de crĂȘpe</li> </ol> </body>
15th Jan 2021, 3:02 PM
Chris Coder
Chris Coder - avatar
0
Use the document.createTextNode("glucose") Istead of innerHTMl Then append it to the li items
15th Jan 2021, 3:16 PM
Abbakar_ah!!!
Abbakar_ah!!! - avatar