HTML | Свойство DOM firstElementChild
Опубликовано: 3 Февраля, 2022
Свойство HTML DOM firstElementChild вернет первого дочернего элемента любого узла PreRequist DOM (объектная модель документа)
Параметры:
Параметры не требуются.
Возвращаемое значение:
Значения, возвращаемые свойством firstElementChild, следующие:
Syntax
node.firstElementChild()
Example:
<!DOCTYPE html> < html > < head > < head > HTML | DOM firstElementChild Property </ head > < script > // JavaScript code to get the node whose // id is "Section" function example() { // x is used to store the element // whose id is "Sections". var x = document.getElementById("Sections" + ).firstElementChild.innerHTML; document.getElementById("GeeksForGeeks sections" + " first node").innerHTML = x; } </ script > </ head > < body > < p >GeeksForGeeksTopics</ p > < ul id = "Sections" > < li >Array</ li > < li >LinkedList</ li > < li >Stack</ li > < li >Queue</ li > < li >Tree</ li > < li >Graph</ li > </ ul > < p > Click the button to get the first child of the node having id is "Sections". </ p > <!--button is used to run example function--> < button onclick = "example()" >Click</ button > < p id = "GeeksForGeeks sections first node" ></ p > </ body > </ html > |
Output
Supported Browsers: The browser supported by DOM firstElementChild are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari