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..7cf524f76 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` সর্বদা বড়হাতের হয়। +2. কমেন্টটি হল একমাত্র চাইল্ড নোড, সুতরাং আমরা একে `body.firstChild` প্রপার্টিতে পাব। +3. কমেন্ট এর কন্টেন্ট হল `"BODY"` যা আমরা `data` প্রপার্টিতে পাব। \ No newline at end of file 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..9c72b4336 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 @@ -4,7 +4,7 @@ importance: 3 # Tag in comment -What does this code show? +কোডটি কি দেখাবে? ```html ``` -In modern scripts, we can use `instanceof` and other class-based tests to see the node type, but sometimes `nodeType` may be simpler. We can only read `nodeType`, not change it. +মডার্ন জাভাস্ক্রিপ্টে, আমরা `instanceof` এর সাহায্যে নোড টাইপ যাচাই করতে পারি, কিন্তু অনেক সময় `nodeType` ও কাজে আসে। `nodeType` হল রিড-অনলি, এটি পরিবর্তনযোগ্য নয়। -## Tag: nodeName and tagName +## ট্যাগ: nodeName এবং tagName -Given a DOM node, we can read its tag name from `nodeName` or `tagName` properties: +DOM নোড হতে, আমরা ট্যাগ নামটি `nodeName` বা `tagName` প্রপার্টির সাহায্যে পড়তে পারি: -For instance: +উদাহরণস্বরূপ: ```js run alert( document.body.nodeName ); // BODY alert( document.body.tagName ); // BODY ``` -Is there any difference between `tagName` and `nodeName`? +`tagName` এবং `nodeName` এর মাঝে কি কোন পার্থক্য আছে? -Sure, the difference is reflected in their names, but is indeed a bit subtle. +হ্যাঁ, প্রপার্টিগুলোর পার্থক্য নামগুলোতেই প্রতিফলিত হয়, তবে এছাড়াও কিছুটা সূক্ষ্ম পার্থক্য আছে। -- The `tagName` property exists only for `Element` nodes. -- The `nodeName` is defined for any `Node`: - - for elements it means the same as `tagName`. - - for other node types (text, comment, etc.) it has a string with the node type. +- `tagName` প্রপার্টি শুধুমাত্র `Element` নোড এ থাকে। +- `nodeName` প্রপার্টি যে কোন `Node` এর জন্য: + - এলিমেন্টের জন্য `tagName` একই। + - অন্যান্য নোড টাইপের জন্য যেমন (text, comment, ইত্যাদি)। -In other words, `tagName` is only supported by element nodes (as it originates from `Element` class), while `nodeName` can say something about other node types. +অন্যভাবে বলা যায়, `tagName` শুধুমাত্র এলিমেন্ট নোডের জন্য কাজ করে (অর্থাৎ `Element` ক্লাসের জন্য), অন্যদিকে `nodeName` এ যেকোন নোড টাইপের নাম পেতে পারি। -For instance, let's compare `tagName` and `nodeName` for the `document` and a comment node: +উদাহরণস্বরূপ, চলুন `document` এবং *comment* node এর জন্য `tagName` এবং `nodeName` এর পার্থক্য দেখি: ```html run ``` -If we only deal with elements, then we can use both `tagName` and `nodeName` - there's no difference. +যদি আমরা এলিমেন্ট নিয়ে কাজ করি, তাহলে `tagName` এবং `nodeName` উভয়ই ব্যবহার করতে পারব - তাদের মাঝে কোন পার্থক্য নাই। -```smart header="The tag name is always uppercase except in XML mode" +```smart header="XML মোড ব্যাতীত ট্যাগ নাম সর্বদা বড় হাতের হয়" The browser has two modes of processing documents: HTML and XML. Usually the HTML-mode is used for webpages. XML-mode is enabled when the browser receives an XML-document with the header: `Content-Type: application/xml+xhtml`. In HTML mode `tagName/nodeName` is always uppercased: it's `BODY` either for `` or ``. @@ -196,13 +196,13 @@ In XML mode the case is kept "as is". Nowadays XML mode is rarely used. ``` -## innerHTML: the contents +## innerHTML: কন্টেন্ট -The [innerHTML](https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML) property allows to get the HTML inside the element as a string. +[innerHTML](https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML) প্রপার্টিতে এলিমেন্টের কন্টেন্ট স্ট্রিং হিসেবে নেই। -We can also modify it. So it's one of the most powerful ways to change the page. +আমরা এর সাহায্যে কন্টেন্ট পরিবর্তনও করতে পারি। সুতরাং DOM এ পরিবর্তনের অন্যতম উপায় হল এটি। -The example shows the contents of `document.body` and then replaces it completely: +নিচের উদাহরণে `document.body` এর কন্টেন্ট দেখি এবং একে পরিবর্তন করি: ```html run @@ -210,44 +210,44 @@ The example shows the contents of `document.body` and then replaces it completel...
+ // div.outerHTML এর সাহায্যে...
প্রতিস্থাপন */!* div.outerHTML = 'A new element
'; // (*) *!* - // Wow! 'div' is still the same! + // Wow! 'div' এখনো আগের মত! */!* alert(div.outerHTML); //A new element
`. In the outer document (the DOM) we can see the new content instead of the `A new element
` দ্বারা প্রতিস্থাপন করি। আউটার ডকুমেন্টে আমরা `A new element
` was inserted in its place. +সুতরাং চলুন দেখি `div.outerHTML=...` এর ক্ষেত্রে কি হয়: +- ডকুমেন্ট হতে `div` টি রিমুভ হবে। +- তার স্থলে আরেকটি নতুন HTML `A new element
` প্রতিস্থাপিত হবে। - `div` still has its old value. The new HTML wasn't saved to any variable. -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 -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`। প্রাক্টিক্যাল ইউজ কেসে দুইটির কাজ একই, তবে কিছু সামান্য পার্থক্য আছে। আমরা এখানে `data` প্রপার্টি ব্যবহার করব, কেননা এটি সংক্ষিপ্তরূপ। -An example of reading the content of a text node and a comment: +কমেন্ট এবং টেক্সট নোডের কন্টেন্ট পড়ার একটি উদাহরণ দেখুন: ```html run height="50" @@ -349,9 +349,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 @@ -359,13 +359,13 @@ Sometimes developers embed information or template instructions into HTML in the ``` -...Then JavaScript can read it from `data` property and process embedded instructions. +...তারপরে জাভাস্ক্রিপ্ট এটি `data` প্রপার্টির সাহায্যে পড়তে পারে এবং এম্বেড থাকা এর নিয়ম হতে প্রসেস করতে পারে। -## textContent: pure text +## textContent: শুধুই টেক্সট -The `textContent` provides access to the *text* inside the element: only text, minus all `