let content = document.getElementById('menu');
let firstChild = content.firstChild.nodeName;
console.log(firstChild);Code language: JavaScript (javascript)
var listElement = document.getElementById("element");
// could also use listElement.children;
var listElements = listElement.getElementsByTagName('div');
for (i = 0; i < listElements.length; i++) {
alert(listElements[i].id);
}
var child_element = document.querySelector("#id").children[0];
//Where # defines id and '.' a class. And 0 argument the first child element
let firstChild = parentElement.firstChild;
Code language: JavaScript (javascript)
let lastChild = parentElement.lastElementChild;Code language: JavaScript (javascript)