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

Commit 22233c4

Browse files
adding last section to the DOM
1 parent 0032146 commit 22233c4

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

‎04_dom.md‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,39 @@ document.body.appendChild(myFragment);
418418
<a name="TraversingAndRemovingNodes"></a>
419419
## **Traversing and removing nodes**
420420

421+
We have some properties avaible for us to work with elements, like:
422+
- ```el.children```
423+
- ```el.firstElementChild```
424+
- ```el.lastElementChild```
425+
- ```el.previousElementSibling```
426+
- ```el.nextElementSibling```
427+
- ```el.parentElement```
428+
429+
We also have these properties for nodes:
430+
- ```el.childNodes```
431+
- ```el.firstChild```
432+
- ```el.lastChild```
433+
- ```el.previousSibling```
434+
- ```el.nextSibling```
435+
- ```el.parentNode```
436+
437+
> **Note:** the word ```el``` means Element
438+
439+
you can remove by using ```remove()```, for example: lets create a paragraph, turn into and element, added to the page and then remove it.
421440

441+
```js
442+
const p = document.createElement('p');
443+
p.textContent = 'i will be removed';
444+
document.body.appendChild(p);
422445

446+
p.remove();
447+
```
423448

424-
425-
426-
449+
this will remove the paragraph from the page, but still able in memory, so you can simply added again by using ```appendChild``` or other way to add the element into the page.
427450

428451
<br>
429452

430453
---
431454
back to [Table of Content](tableOfContent.md)
432455
previous [The Tricky Bits](03_bits.md)
433-
next []()
456+
next [Events](05_events.md)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /