Fixes in 21_day_dom.md

Fixed some typos in 21_day_dom.md.
In line 138, querySelector can select any element, not only h1.
pull/309/head
Joseph Bak 4 years ago committed by GitHub
parent a22baede03
commit faf329ba3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -135,10 +135,10 @@ The _document.querySelector_ method can select an HTML or HTML elements by tag n
```js
let firstTitle = document.querySelector('h1') // select the first available h1 element
let firstTitle = document.querySelector('#first-title') // select id with first-title
let firstTitle = document.querySelector('.title') // select the first available h1 element with class title
let firstTitle = document.querySelector('.title') // select the first available element with class title
```
**_querySelectorAll_**: can be used to select html element by its tag name or class. It return a nodeList which is an array like object which support array methods. We can use **_for loop_** or **_forEach_** to loop through each nodeList elements.
**_querySelectorAll_**: can be used to select html element by its tag name or class. It returns a nodeList which is an array like object which supports array methods. We can use **_for loop_** or **_forEach_** to loop through each nodeList elements.
```js
const allTitles = document.querySelectorAll('h1')

Loading…
Cancel
Save