Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DOM navigation#328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dolgachio merged 13 commits intojavascript-tutorial:masterfromdolgachio:master
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
d1bfa37
1-js/09-classes/06-instanceof: Translation
dolgachioDec 5, 2021
f976080
Merge branch 'master' of github.com:javascript-tutorial/uk.javascript…
dolgachioJan 9, 2022
fba8269
1-js/10-error-handling/2-custom-errors: Translation
dolgachioJan 9, 2022
26021bc
Merge branch 'javascript-tutorial:master' into master
dolgachioJan 20, 2022
f20ee14
Translate 2-ui titles
dolgachioJan 20, 2022
cf87d7f
Apply suggestions from code review
tarasyyykJan 20, 2022
7758d34
Merge branch 'javascript-tutorial:master' into master
dolgachioMar 21, 2022
e407870
2-ui/1-document/03-dom-navigation: part 1
dolgachioApr 20, 2022
f1c2506
2-ui/1-document/03-dom-navigation: part 2
dolgachioApr 20, 2022
ced6139
2-ui/1-document/03-dom-navigation: tasks
dolgachioApr 20, 2022
6ed9194
Merge branch 'master' of github.com:stas-dolgachov/uk.javascript.info
dolgachioApr 20, 2022
539e8a1
2-ui/1-document/03-dom-navigation: 4-task translation
dolgachioApr 21, 2022
b1f74dc
Apply suggestions from code review
tarasyyykApr 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions2-ui/1-document/03-dom-navigation/1-dom-children/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
There are many ways, for instance:
Існує багато способів, наприклад:


The`<div>` DOM node:
До DOM вузла`<div>`:

```js
document.body.firstElementChild
//or
//або
document.body.children[0]
//or (the first node is space, so we take 2nd)
//або (перший вузол -- це пробіл, тому беремо 2-й)
document.body.childNodes[1]
```

The`<ul>` DOM node:
До DOM вузла`<ul>`:

```js
document.body.lastElementChild
//or
//або
document.body.children[1]
```

The second `<li>` (with Pete):
До другого `<li>` (Петро):

```js
//get <ul>,and then get its last element child
//отримати <ul>,а потім отримати його останній дочірній елемент
document.body.lastElementChild.lastElementChild
```
18 changes: 9 additions & 9 deletions2-ui/1-document/03-dom-navigation/1-dom-children/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,23 +2,23 @@ importance: 5

---

#DOM children
#Діти у DOM

Look at this page:
Подивіться на цю сторінку:

```html
<html>
<body>
<div>Users:</div>
<div>Користувачи:</div>
<ul>
<li>John</li>
<li>Pete</li>
<li>Іван</li>
<li>Петро</li>
</ul>
</body>
</html>
```

For each of the following, give at least one way of how to access them:
-The`<div>` DOM node?
-The`<ul>` DOM node?
-The second `<li>` (with Pete)?
Вкажіть принаймні один спосіб доступу до кожного з перелічених нижче DOM вузлів:
-До DOM вузла`<div>`?
-До DOM вузла`<ul>`?
-До другого `<li>` (Петро)?
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1.Yes, true. The element`elem.lastChild`is always the last one, it has no `nextSibling`.
2.No, wrong, because`elem.children[0]`is the first child *among elements*.But there may exist non-element nodes before it. So `previousSibling`may be a text node.
1.Так, це правда. Елемент`elem.lastChild`завжди останній, у нього немає `nextSibling`.
2.Ні, це неправда, тому що`elem.children[0]`— перший дочірній *серед елементів*.Але перед ним можуть існувати вузли інших типів. Отже, `previousSibling`може бути, наприклад, текстовим вузлом.

Please note: for both cases if there are no children, then there will be an error.
Зверніть увагу: в обох випадках якщо немає дітей, то буде помилка.

If there are no children, `elem.lastChild`is`null`,so we can't access`elem.lastChild.nextSibling`.And the collection`elem.children`is empty (like an empty array `[]`).
Якщо дочірніх елементів немає, `elem.lastChild`матиме значення`null`,тому ми не зможемо отримати доступ до`elem.lastChild.nextSibling`.А колекція`elem.children`порожня (як порожній масив `[]`).
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,9 @@ importance: 5

---

#The sibling question
#Питання про сусідів

If `elem` --is an arbitraryDOMelement node...
Якщо `elem` --це довільнийDOMелемент...

-Is it true that`elem.lastChild.nextSibling`is always `null`?
-Is it true that`elem.children[0].previousSibling`is always`null`?
-Чи правда що`elem.lastChild.nextSibling`завжди `null`?
-Чи правда що`elem.children[0].previousSibling`завжди`null`?
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
We'll be using`rows`and `cells`properties to access diagonal table cells.
Ми будемо використовувати властивості`rows`та `cells`для доступу до діагональних клітинок таблиці.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,17 +2,17 @@ importance: 5

---

#Select all diagonal cells
#Виділіть усі діагональні клітинки

Write the code to paint all diagonal table cells in red.
Напишіть код, щоб зафарбувати всі діагональні клітинки таблиці червоним кольором.

You'll need to get all diagonal `<td>`from the`<table>`and paint them using the code:
Вам потрібно буде отримати всі діагоналі `<td>`з`<table>`і розфарбувати їх за допомогою коду:

```js
// tdshould be the reference to the table cell
//уtdмає бути посилання на клітинку таблиці
td.style.backgroundColor = 'red';
```

The result should be:
Результат повинен бути таким:

[iframe src="solution" height=180]
Loading

[8]ページ先頭

©2009-2025 Movatter.jp