From b2f7515c5db6dee1e58064324becf525fc6c2264 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 30 Nov 2017 18:56:37 +0300 Subject: [PATCH] Update article.md --- 2-ui/1-document/04-searching-elements-dom/article.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/2-ui/1-document/04-searching-elements-dom/article.md b/2-ui/1-document/04-searching-elements-dom/article.md index 50674218..e7382a01 100644 --- a/2-ui/1-document/04-searching-elements-dom/article.md +++ b/2-ui/1-document/04-searching-elements-dom/article.md @@ -84,7 +84,7 @@ let divs = document.getElementsByTagName('div'); This method is callable in the context of any DOM element. -Let's find all `input` inside the table: +Let's find all `input` tags inside the table: ```html run height=50 @@ -123,16 +123,16 @@ The `"s"` letter is absent in `getElementById`, because it returns a single elem ``` ````warn header="It returns a collection, not an element!" -Another widespread novice mistake is to write like: +Another widespread novice mistake is to write: ```js // doesn't work document.getElementsByTagName('input').value = 5; ``` -That won't work, because it takes a *collection* of inputs and assigns the value to it, rather to elements inside it. +That won't work, because it takes a *collection* of inputs and assigns the value to it rather than to elements inside it. -We should either iterate over the collection or get an element by the number, and then assign, like this: +We should either iterate over the collection or get an element by its index, and then assign, like this: ```js // should work (if there's an input) @@ -374,7 +374,7 @@ Other methods can be called on elements too. For instance `elem.querySelectorAll Besides that: - There is `elem.matches(css)` to check if `elem` matches the given CSS selector. -- There is `elem.closest(css)` to look for a nearest ancestor that matches the given CSS-selector. The `elem` itself is also checked. +- There is `elem.closest(css)` to look for the nearest ancestor that matches the given CSS-selector. The `elem` itself is also checked. And let's mention one more method here to check for the child-parent relationship: - `elemA.contains(elemB)` returns true if `elemB` is inside `elemA` (a descendant of `elemA`) or when `elemA==elemB`.