Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

DOM ul element, how to create it?

I have this element at index.html:

<div id="app"></div>

How can I write a query to get that DOM element?
And create a new UL element and append it to the previously mentioned <div> element?

Like here:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function displayUsers(users) {
  // ??????????
};

>Solution :

const ul = document.createElement('ul')
const li = document.createElement('li')
const textNode = document.createTextNode('some text')
li.appendChild(textNode)
ul.appendChild(li)
document.getElementById('app').appendChild(ul)

an example here
https://www.w3schools.com/jsref/met_node_appendchild.asp

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading