Skip to content

Commit e111d60

Browse files
authored
Merge pull request #314 from usernamehw/patch-2
Update article.md
2 parents be108af + b2f7515 commit e111d60

File tree

1 file changed

+5
-5
lines changed
  • 2-ui/1-document/04-searching-elements-dom

1 file changed

+5
-5
lines changed

2-ui/1-document/04-searching-elements-dom/article.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let divs = document.getElementsByTagName('div');
8484

8585
This method is callable in the context of any DOM element.
8686

87-
Let's find all `input` inside the table:
87+
Let's find all `input` tags inside the table:
8888

8989
```html run height=50
9090
<table id="table">
@@ -123,16 +123,16 @@ The `"s"` letter is absent in `getElementById`, because it returns a single elem
123123
```
124124
125125
````warn header="It returns a collection, not an element!"
126-
Another widespread novice mistake is to write like:
126+
Another widespread novice mistake is to write:
127127
128128
```js
129129
// doesn't work
130130
document.getElementsByTagName('input').value = 5;
131131
```
132132

133-
That won't work, because it takes a *collection* of inputs and assigns the value to it, rather to elements inside it.
133+
That won't work, because it takes a *collection* of inputs and assigns the value to it rather than to elements inside it.
134134

135-
We should either iterate over the collection or get an element by the number, and then assign, like this:
135+
We should either iterate over the collection or get an element by its index, and then assign, like this:
136136

137137
```js
138138
// should work (if there's an input)
@@ -374,7 +374,7 @@ Other methods can be called on elements too. For instance `elem.querySelectorAll
374374
Besides that:
375375
376376
- There is `elem.matches(css)` to check if `elem` matches the given CSS selector.
377-
- There is `elem.closest(css)` to look for a nearest ancestor that matches the given CSS-selector. The `elem` itself is also checked.
377+
- There is `elem.closest(css)` to look for the nearest ancestor that matches the given CSS-selector. The `elem` itself is also checked.
378378
379379
And let's mention one more method here to check for the child-parent relationship:
380380
- `elemA.contains(elemB)` returns true if `elemB` is inside `elemA` (a descendant of `elemA`) or when `elemA==elemB`.

0 commit comments

Comments
 (0)