Skip to content

Commit cc577c5

Browse files
Update article.md
1 parent b00e6d2 commit cc577c5

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • 2-ui/1-document/04-searching-elements-dom

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,20 @@
4949
<div id="elem"></div>
5050

5151
<script>
52-
let elem = 5; // الان مقدار elem، 5 <div id="elem"> است نه ارجاعی به
53-
است نه ارجاعی به <div id="elem"> 5ُ، elem الان مقدار
54-
52+
let elem = 5; // <div id="elem"> پنج است، نه ارجاعی به elem الان مقدار
53+
5554
alert(elem); // 5
5655
</script>
5756
```
5857

5958
```warn header="Please don't use id-named global variables to access elements"
60-
This behavior is described [in the specification](https://html.spec.whatwg.org/multipage/window-object.html#named-access-on-the-window-object), but it is supported mainly for compatibility.
59+
این رفتار در [in the specification](https://html.spec.whatwg.org/multipage/window-object.html#named-access-on-the-window-object) توضیح داده شده است اما به طور معمول برای سازگاری پشتیبانی می‌شود.
6160
62-
The browser tries to help us by mixing namespaces of JS and DOM. That's fine for simple scripts, inlined into HTML, but generally isn't a good thing. There may be naming conflicts. Also, when one reads JS code and doesn't have HTML in view, it's not obvious where the variable comes from.
61+
مرورگر تلاش می‌کند که با ترکیب namespaceهای JS و DOM به ما کمک کند. این کار برای scriptهای ساده‌ای که به صورت inline در HTML نوشته شده اند مناسب است،‌اما به طور کلی ایده‌ی خوبی نیست. ممکن است تعارض‌‌هایی در نام‌گذاری به وجود آورد. همچنین، وقتی کسی کد JS را می‌خواند و به HTML دسترسی ندارد، مشخص نیست که متغیر از کجا می‌آید.
6362
64-
Here in the tutorial we use `id` to directly reference an element for brevity, when it's obvious where the element comes from.
63+
اینحا در این آموزش وقتی مشخص است که element از کجا آمده است، ما برای کوتاهی و اختصار از `id` استفاده می‌کنیم تا به طور مستقیم به یک element ارجاع دهیم.
6564
66-
In real life `document.getElementById` is the preferred method.
65+
ترجیح داده می‌شودdocument.getElementById` در زندگی واقعی
6766
```
6867

6968
```smart header="The `id` must be unique"

0 commit comments

Comments
 (0)