Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prependchild in javascript

<ul id="app">
    <li>HTML</li>
</ul>

<script>
let app = document.querySelector('#app');

let langs = ['CSS','JavaScript','TypeScript'];

let nodes = langs.map(lang => {
    let li = document.createElement('li');
    li.textContent = lang;
    return li;
});

app.prepend(...nodes);
</script>
 
PREVIOUS NEXT
Tagged: #prependchild #javascript
ADD COMMENT
Topic
Name
5+8 =