en.javascript.info/2-ui/1-document/03-dom-navigation/1-dom-children/solution.md
Ilya Kantor 508969c13f up
2017-02-28 12:54:48 +03:00

446 B

There are many ways, for instance:

The <div> DOM node:

document.body.firstElementChild
// or
document.body.children[0]
// or (the first node is space, so we take 2nd)
document.body.childNodes[1]

The <ul> DOM node:

document.body.lastElementChild
// or
document.body.children[1]

The second <li> (with Pete):

// get <ul>, and then get its last element child
document.body.lastElementChild.lastElementChild