Skip to content

Commit ee6da54

Browse files
authored
Update article.md
1 parent e8f106f commit ee6da54

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

2-ui/1-document/02-dom-nodes/article.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@ libs:
66

77
# DOM tree
88

9-
The backbone of an HTML document is tags.
9+
Tulang punggung dari dokumen HTML adalah tag.
1010

11-
According to the Document Object Model (DOM), every HTML tag is an object. Nested tags are "children" of the enclosing one. The text inside a tag is an object as well.
11+
Berdasarkan Document Object Model (DOM), setiap tag HTML merupakan sebuah objek. Tag berlapis adalah "anak" dari tag yang melampirkan. Teks di dalam sebuah tag merupakan sebuah objek juga.
1212

13-
All these objects are accessible using JavaScript, and we can use them to modify the page.
13+
Semua objek ini dapat diakses menggunakan JavaScript, dan kita bisa menggunakannya untuk memodifikasi halaman.
1414

15-
For example, `document.body` is the object representing the `<body>` tag.
15+
Misalnya, `document.body` merupakan objek yang merepresentasikan tag `<body>`.
1616

17-
Running this code will make the `<body>` red for 3 seconds:
17+
Menjalankan kode ini akan membuat `<body>` menjadi merah selama 3 detik.
1818

1919
```js run
20-
document.body.style.background = 'red'; // make the background red
20+
document.body.style.background = 'red'; // buat background menjadi merah
2121

22-
setTimeout(() => document.body.style.background = '', 3000); // return back
22+
setTimeout(() => document.body.style.background = '', 3000); // kembalikan seperti semula
2323
```
2424

25-
Here we used `style.background` to change the background color of `document.body`, but there are many other properties, such as:
25+
Disini kita menggunakan `style.background` untuk mengubah warna background `document.body`, tetapi ada banyak properti lain, seperti:
2626

27-
- `innerHTML` -- HTML contents of the node.
28-
- `offsetWidth` -- the node width (in pixels)
29-
- ...and so on.
27+
- `innerHTML` -- Konten HTML dari node.
28+
- `offsetWidth` -- lebar node (dalam piksel)
29+
- ...dan seterusnya.
3030

31-
Soon we'll learn more ways to manipulate the DOM, but first we need to know about its structure.
31+
Kita akan segera mempelajari lebih banyak cara untuk memanipulasi DOM, tetapi pertama-tama kita perlu mengetahui tentang strukturnya.
3232

33-
## An example of the DOM
33+
## Contoh dari DOM
3434

35-
Let's start with the following simple document:
35+
Mari kita mulai dengan dokumen sederhana berikut:
3636

3737
```html run no-beautify
3838
<!DOCTYPE HTML>
@@ -46,7 +46,7 @@ Let's start with the following simple document:
4646
</html>
4747
```
4848

49-
The DOM represents HTML as a tree structure of tags. Here's how it looks:
49+
DOM menggambarkan HTML seperti struktur pohon pada tag. Begini tampilannya:
5050

5151
<div class="domtree"></div>
5252

@@ -57,31 +57,31 @@ drawHtmlTree(node1, 'div.domtree', 690, 320);
5757
</script>
5858

5959
```online
60-
On the picture above, you can click on element nodes and their children will open/collapse.
60+
Pada gambar di atas, Anda dapat mengklik node elemen dan anaknya akan membuka/menutup.
6161
```
6262

63-
Every tree node is an object.
63+
Setiap node pohon merupakan sebuah objek.
6464

65-
Tags are *element nodes* (or just elements) and form the tree structure: `<html>` is at the root, then `<head>` and `<body>` are its children, etc.
65+
Tag-tag merupakan *node elemen* (atau hanya elemen) dan membentuk struktur pohon: `<html>` merupakan root, kemudian `<head>` dan `<body>` adalah anak-anaknya, dll.
6666

67-
The text inside elements forms *text nodes*, labelled as `#text`. A text node contains only a string. It may not have children and is always a leaf of the tree.
67+
Teks di dalam elemen-elemen membentuk *node teks*, dilabeli sebagai `#text`. Sebuah node teks hanya berisi string. Ia mungkin tidak memiliki anak-anak dan selalu menjadi daun pohon.
6868

69-
For instance, the `<title>` tag has the text `"About elk"`.
69+
Misalnya, tag `<title>` memiliki teks `"About elk"`
7070

71-
Please note the special characters in text nodes:
71+
Harap perhatikan karakter khusus dalam node teks:
7272

73-
- a newline: `` (in JavaScript known as `\n`)
74-
- a space: ``
73+
- baris baru: `` (di dalam JavaScript seperti `\n`)
74+
- spasi: ``
7575

76-
Spaces and newlines are totally valid characters, like letters and digits. They form text nodes and become a part of the DOM. So, for instance, in the example above the `<head>` tag contains some spaces before `<title>`, and that text becomes a `#text` node (it contains a newline and some spaces only).
76+
Spasi dan baris baru adalah karakter yang benar-benar valid, seperti huruf-huruf dan angka-angka. Mereka membentuk node teks dan menjadi bagian dari DOM. Jadi, misalnya, pada contoh di atas, tag `<head>` berisi beberapa spasi sebelum `<title>`, dan teks tersebut menjadi node `#teks` (ini berisi baris baru dan hanya beberapa spasi).
7777

78-
There are only two top-level exclusions:
79-
1. Spaces and newlines before `<head>` are ignored for historical reasons.
80-
2. If we put something after `</body>`, then that is automatically moved inside the `body`, at the end, as the HTML spec requires that all content must be inside `<body>`. So there can't be any spaces after `</body>`.
78+
Hanya ada dua pengecualian top-level:
79+
1. Spasi dan baris baru sebelum `<head>` diabaikan karena alasan historis.
80+
2. Jika kita meletakkan sesuatu setelah `</body>`, maka secara otomatis dipindahkan ke dalam `body`, di bagian bawah, karena spesifikasi HTML mengharuskan semua konten harus berada di dalam `<body>`. Jadi tidak boleh ada spasi setelah `</body>`.
8181

82-
In other cases everything's straightforward -- if there are spaces (just like any character) in the document, then they become text nodes in the DOM, and if we remove them, then there won't be any.
82+
Dalam kasus lain semuanya mudah -- Jika ada spasi-spasi (seperti karakter lainnya) di dalam dokumen, maka mereka menjadi node teks di DOM tersebut, dan jika kita menghapusnya, maka tidak akan ada.
8383

84-
Here are no space-only text nodes:
84+
Berikut tidak ada node teks khusus spasi:
8585

8686
```html no-beautify
8787
<!DOCTYPE HTML>

0 commit comments

Comments
 (0)