how to add a child to a parent element js
function createMenuItem(name) {
let li = document.createElement('li');
li.textContent = name;
return li;
}
// get the ul#menu
const menu = document.querySelector('#menu');
// add menu item
menu.appendChild(createMenuItem('Home'));
menu.appendChild(createMenuItem('Services'));
menu.appendChild(createMenuItem('About Us'));
function createMenuItem(name) {
let li = document.createElement('li');
li.textContent = name;
return li;
}
// get the ul#menu
const menu = document.querySelector('#menu');
// add menu item
menu.appendChild(createMenuItem('Home'));
menu.appendChild(createMenuItem('Services'));
menu.appendChild(createMenuItem('About Us'));
Also in JavaScript:
- send json body http get flutter
- javascript get length of object
- merge array in js
- statusbar reactnati
- get json by id
- settimeout in angular
- do you need a semicolon in javascript
- Email validation using javascript
- How do you call a functional component in React
- multiple case switch javascript
- js prompt
- enzyme hasclass example
- javascript extract array from object
- if keypress javascript
- nohup nodemon
- bodyparser express
- mat slider in a reactve form
- javascript get width of a div
- how to make page scroll to the top jsx
- three js examples
- javascript to detect browser
- firebase react js
- add sass to react
- send event to child component angular