js get child element code example
Example 1: get child element by class javascript
var element = document.querySelector('#Element');
var elementChildren = element.querySelectorAll('.Element-child');
Example 2: get child of child javascript
var li = document.querySelector("li");
var number = 13;
li.children[0].children[0].innerHTML = number;
Example 3: how to get child element in javascript
let firstChild = parentElement.firstChild;
Code language: JavaScript (javascript)
Example 4: how to get child element in javascript
let lastChild = parentElement.lastElementChild;Code language: JavaScript (javascript)