diff --git a/2-ui/1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/solution.md b/2-ui/1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/solution.md index 52c34640a..cb6dffc50 100644 --- a/2-ui/1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/solution.md +++ b/2-ui/1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/solution.md @@ -1,8 +1,8 @@ -There's a catch here. +هناك صيد هنا. -At the time of ` ``` -What's going on step by step: +ما يحدث خطوة بخطوة: -1. The content of `` is replaced with the comment. The comment is ``, because `body.tagName == "BODY"`. As we remember, `tagName` is always uppercase in HTML. -2. The comment is now the only child node, so we get it in `body.firstChild`. -3. The `data` property of the comment is its contents (inside ``): `"BODY"`. +1. يتم استبدال محتوى "" بالتعليق. التعليق هو `` ، لأن `body.tagName ==" BODY "`. كما نتذكر ، فإن `tagName` دائمًا ما تكون أحرفًا كبيرة بتنسيق HTML. +2. التعليق هو الآن العقدة الفرعية الوحيدة ، لذلك نحصل عليه في `body.firstChild`. +3. خاصية "البيانات" للتعليق هي محتوياته (داخل ``): "" BODY "`. diff --git a/2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/task.md b/2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/task.md index efe50b48f..cfc493229 100644 --- a/2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/task.md +++ b/2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/task.md @@ -1,10 +1,10 @@ -importance: 3 +درجة الأهمية: 3 --- -# Tag in comment +# تاج في تعليق -What does this code show? +ماذا يبين هذا الكود؟ ```html ``` -**Beware: unlike `innerHTML`, writing to `outerHTML` does not change the element. Instead, it replaces it in the DOM.** +** احذر: على عكس "innerHTML" ، لا تؤدي الكتابة إلى "outerHTML" إلى تغيير العنصر. بدلاً من ذلك ، يتم استبداله في DOM. ** -Yeah, sounds strange, and strange it is, that's why we make a separate note about it here. Take a look. +نعم ، يبدو غريبًا ، وغريبًا ، لهذا السبب نقوم بعمل ملاحظة منفصلة عنه هنا. إلق نظرة. -Consider the example: +تأمل في المثال: ```html run
Hello, world!
@@ -308,28 +307,28 @@ Consider the example: ``` -Looks really odd, right? +تبدو غريبة حقا ، أليس كذلك؟ -In the line `(*)` we replaced `div` with `

A new element

`. In the outer document (the DOM) we can see the new content instead of the `
`. But, as we can see in line `(**)`, the value of the old `div` variable hasn't changed! +في السطر `(*)` استبدلنا `div` بـ`

عنصر جديد `. في المستند الخارجي (DOM) ، يمكننا رؤية المحتوى الجديد بدلاً من `

`. ولكن ، كما نرى في السطر `(**)` ، لم تتغير قيمة متغير `div` القديم! -The `outerHTML` assignment does not modify the DOM element (the object referenced by, in this case, the variable 'div'), but removes it from the DOM and inserts the new HTML in its place. +لا يقوم تعديل "outerHTML" بتعديل عنصر DOM (الكائن المشار إليه ، في هذه الحالة ، المتغير 'div') ، ولكنه يزيله من DOM ويدرج HTML الجديد في مكانه. -So what happened in `div.outerHTML=...` is: -- `div` was removed from the document. -- Another piece of HTML `

A new element

` was inserted in its place. -- `div` still has its old value. The new HTML wasn't saved to any variable. +ما حدث في `div.outerHTML = ...` هو: +- تمت إزالة `div` من المستند. +- تم إدراج جزء آخر من HTML "

عنصر جديد " في مكانه. +- `div` لا تزال لها قيمتها القديمة. لم يتم حفظ HTML الجديد في أي متغير. -It's so easy to make an error here: modify `div.outerHTML` and then continue to work with `div` as if it had the new content in it. But it doesn't. Such thing is correct for `innerHTML`, but not for `outerHTML`. +من السهل جدًا ارتكاب خطأ هنا: قم بتعديل `div.outerHTML` ثم تابع العمل مع` div` كما لو كان به محتوى جديد فيه. لكنها لا تفعل ذلك. هذا الشيء صحيح بالنسبة لـ "innerHTML" ، ولكن ليس لـ "outerHTML". -We can write to `elem.outerHTML`, but should keep in mind that it doesn't change the element we're writing to ('elem'). It puts the new HTML in its place instead. We can get references to the new elements by querying the DOM. +يمكننا الكتابة إلى "elem.outerHTML" ، ولكن يجب أن نضع في اعتبارنا أنه لا يغير العنصر الذي نكتب إليه ("elem"). بدلاً من ذلك ، تضع HTML الجديد في مكانه. يمكننا الحصول على مراجع للعناصر الجديدة عن طريق الاستعلام عن DOM. -## nodeValue/data: text node content +## nodeValue / data: محتوى عقدة النص -The `innerHTML` property is only valid for element nodes. +خاصية `innerHTML` صالحة لعقد العناصر فقط. -Other node types, such as text nodes, have their counterpart: `nodeValue` and `data` properties. These two are almost the same for practical use, there are only minor specification differences. So we'll use `data`, because it's shorter. +أنواع العقد الأخرى ، مثل العقد النصية ، لها نظيرها: خصائص `nodeValue` و` data`. هذان النوعان متشابهان تقريبًا للاستخدام العملي ، ولا توجد سوى اختلافات طفيفة في المواصفات. لذا سنستخدم "البيانات" لأنها أقصر. -An example of reading the content of a text node and a comment: +مثال على قراءة محتوى العقدة النصية والتعليق: ```html run height="50" @@ -349,9 +348,9 @@ An example of reading the content of a text node and a comment: ``` -For text nodes we can imagine a reason to read or modify them, but why comments? +بالنسبة للعقد النصية ، يمكننا تخيل سبب لقراءتها أو تعديلها ، ولكن لماذا التعليقات؟ -Sometimes developers embed information or template instructions into HTML in them, like this: +في بعض الأحيان يقوم المطورون بتضمين معلومات أو تعليمات قالب في HTML ، مثل هذا: ```html @@ -359,13 +358,13 @@ Sometimes developers embed information or template instructions into HTML in the ``` -...Then JavaScript can read it from `data` property and process embedded instructions. +... ثم يمكن لجافا سكريبت قراءته من خاصية `البيانات` ومعالجة التعليمات المضمنة. -## textContent: pure text +## textContent: نص خالص -The `textContent` provides access to the *text* inside the element: only text, minus all ``. +يوفر `textContent` الوصول إلى * text * داخل العنصر: النص فقط ، ناقص جميع` `. -For instance: +على سبيل المثال: ```html run

@@ -379,18 +378,18 @@ For instance: ``` -As we can see, only text is returned, as if all `` were cut out, but the text in them remained. +كما نرى ، يتم إرجاع النص فقط ، كما لو تم قطع جميع `` ، لكن النص فيها بقي. -In practice, reading such text is rarely needed. +من الناحية العملية ، نادرًا ما تكون هناك حاجة لقراءة مثل هذا النص. -**Writing to `textContent` is much more useful, because it allows to write text the "safe way".** +** تعد الكتابة إلى "textContent" أكثر فائدة لأنها تتيح لك كتابة النص "بطريقة آمنة". ** -Let's say we have an arbitrary string, for instance entered by a user, and want to show it. +لنفترض أن لدينا سلسلة عشوائية ، على سبيل المثال تم إدخالها من قبل مستخدم ، ونريد إظهارها. -- With `innerHTML` we'll have it inserted "as HTML", with all HTML tags. -- With `textContent` we'll have it inserted "as text", all symbols are treated literally. +- باستخدام "innerHTML" ، سنقوم بإدراج "كـ HTML" ، مع كافة علامات HTML. +- مع "textContent" سنقوم بإدراج "كنص" ، يتم التعامل مع جميع الرموز حرفياً. -Compare the two: +قارن بين الاثنين: ```html run
@@ -404,16 +403,16 @@ Compare the two: ``` -1. The first `
` gets the name "as HTML": all tags become tags, so we see the bold name. -2. The second `
` gets the name "as text", so we literally see `Winnie-the-pooh!`. +1. يحصل الاسم الأول "
" على الاسم "بتنسيق HTML": تصبح جميع العلامات علامات ، لذلك نرى الاسم الغامق. +2. الثانية `
` تحصل على الاسم "كنص" ، لذلك نرى حرفياً " Winnie-the-pooh! `. -In most cases, we expect the text from a user, and want to treat it as text. We don't want unexpected HTML in our site. An assignment to `textContent` does exactly that. +في معظم الحالات ، نتوقع النص من مستخدم ونريد معاملته كنص. لا نريد HTML غير متوقع في موقعنا. يؤدي التعيين إلى `textContent` ذلك بالضبط. -## The "hidden" property +## خاصية "مخفية" -The "hidden" attribute and the DOM property specifies whether the element is visible or not. +تحدد السمة "مخفي" وخاصية DOM ما إذا كان العنصر مرئيًا أم لا. -We can use it in HTML or assign using JavaScript, like this: +يمكننا استخدامه في HTML أو تخصيصه باستخدام JavaScript ، مثل هذا: ```html run height="80"
Both divs below are hidden
@@ -427,10 +426,9 @@ We can use it in HTML or assign using JavaScript, like this: ``` -Technically, `hidden` works the same as `style="display:none"`. But it's shorter to write. - -Here's a blinking element: +من الناحية الفنية ، يعمل `المخفي` تمامًا مثل` style = "display: none" `. لكنها أقصر في الكتابة. +إليك عنصر وامض: ```html run height=50
A blinking element
@@ -440,16 +438,16 @@ Here's a blinking element: ``` -## More properties +## المزيد من الخصائص -DOM elements also have additional properties, in particular those that depend on the class: +تحتوي عناصر DOM أيضًا على خصائص إضافية ، لا سيما تلك التي تعتمد على الفئة: -- `value` -- the value for ``, `