You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/1-document/04-searching-elements-dom/article.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ For instance:
147
147
148
148
## closest
149
149
150
-
*والدهای* یک element عبارتاند از: پدر، پدر پدر، پدر آن و ... . این والدها با یکدیگر زنجیرهای از والدها را از یک عنصر به سمت بالا تشکیل میدهند.
150
+
*والدهای* یک element عبارتاند از: پدر، پدر پدر، پدر آن و ... . این والدها با یکدیگر زنجیرهای از والدها را از یک element به سمت بالا تشکیل میدهند.
151
151
152
152
متد `elem.closest(css)` به دنبال نزدیکترین والدی است که با CSS-selector تطابق دارد. خود `elem` هم شامل این جستجو میشود.
153
153
@@ -177,38 +177,41 @@ For instance:
177
177
178
178
## getElementsBy*
179
179
180
-
There are also other methods to look for nodes by a tag, class, etc.
180
+
همچنین روشهای دیگری برای جستجو برای یک node با tag، class و ... وجود دارد.
181
181
182
-
Today, they are mostly history, as`querySelector`is more powerful and shorter to write.
182
+
امروزه آنها بیشتر تاریخچه هستند چون`querySelector`قدرتمندتر است و برای نوشتن سریعتر است.
183
183
184
-
So here we cover them mainly for completeness, while you can still find them in the old scripts.
184
+
پس اینجا ما بیشتر آنها را برای کامل بودن پوشش میدهیم اما هنوز میتوانید آنها را در scriptهای قدیمی پیدا کنید.
185
185
186
-
-`elem.getElementsByTagName(tag)` looks for elements with the given tag and returns the collection of them. The `tag` parameter can also be a star `"*"` for "any tags".
187
-
-`elem.getElementsByClassName(className)` returns elements that have the given CSS class.
188
-
-`document.getElementsByName(name)` returns elements with the given `name` attribute, document-wide. Very rarely used.
186
+
- عبارت `elem.getElementsByTagName(tag)` به دنبال elementهایی با tag داده شده است و مجموعهی آنها را برمیگرداند. پارامتر `tag` همچنین میتواند یک ستاره باشد `"*"` به معنای تمام tag ها.
189
187
190
-
For instance:
188
+
- عبارت `elem.getElementsByClassName(className)` تمام elementهایی که کلاس CSS داده شده را دارند برمیگرداند.
189
+
190
+
- عبارت `document.getElementsByName(name)`تمام elementهایی که `name` به عنوان attribute به آنها داده شده است را برمیگرداند و بسیار کم استفاده میشود.
191
+
192
+
برای مثال:
191
193
```js
192
-
// get all divs in the document
194
+
195
+
//تمام div های درون document را میگیرد.
193
196
let divs =document.getElementsByTagName('div');
194
197
```
195
198
196
-
Let's find all`input`tags inside the table:
199
+
بیایید تمام tagهای`input`درون این table را پیدا کنیم:
197
200
198
201
```html run height=50
199
202
<tableid="table">
200
203
<tr>
201
-
<td>Your age:</td>
204
+
<td>سن شما:</td>
202
205
203
206
<td>
204
207
<label>
205
-
<inputtype="radio"name="age"value="young"checked> less than 18
208
+
<inputtype="radio"name="age"value="young"checked> کمتر از 18
206
209
</label>
207
210
<label>
208
-
<inputtype="radio"name="age"value="mature"> from 18 to 50
211
+
<inputtype="radio"name="age"value="mature"> از 18 تا 50
209
212
</label>
210
213
<label>
211
-
<inputtype="radio"name="age"value="senior"> more than 60
214
+
<inputtype="radio"name="age"value="senior"> بیشتر از 60
0 commit comments