up
This commit is contained in:
parent
4272b7bb13
commit
508969c13f
168 changed files with 340 additions and 10 deletions
|
@ -0,0 +1,19 @@
|
|||
Let's make a loop over `<li>`:
|
||||
|
||||
```js
|
||||
for (let li of document.querySelector('li')) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
In the loop we need to get the text inside every `li`. We can read it directly from the first child node, that is the text node:
|
||||
|
||||
```js
|
||||
for (let li of document.querySelector('li')) {
|
||||
let title = li.firstChild.data;
|
||||
|
||||
// title is the text in <li> before any other nodes
|
||||
}
|
||||
```
|
||||
|
||||
Then we can get the number of descendants `li.getElementsByTagName('li')`.
|
Loading…
Add table
Add a link
Reference in a new issue