# Finding descendants of elements in JavaScript

`firstElementChild` `lastElementChild` `children`

Given the element `#elem`:

`<ul id="elem"> <li>text</li> <li>text</li> <li>text</li> <li>text</li> <li>text</li> </ul>`

Find the first child of this element and make its text red.

Given the element `#elem`:

`<ul id="elem"> <li>text</li> <li>text</li> <li>text</li> <li>text</li> <li>text</li> </ul>`

Find the last child of this element and make its text red.

Given the element `#elem`:

`<ul id="elem"> <li>text</li> <li>text</li> <li>text</li> <li>text</li> <li>text</li> </ul>`

Find all the children of this element and append the text `'!'` to the end of them.

←→
↑
en ru