From 61d9856115a5fa373e111e2d079a3f900cecf510 Mon Sep 17 00:00:00 2001 From: George Mihov Date: Tue, 27 Feb 2024 15:31:36 -0500 Subject: [PATCH] Introduced classList, corrections, replaced removeChild() with remove(), etc --- src/content/lesson/what-is-dom-define-dom.md | 175 ++++++++++++++----- 1 file changed, 133 insertions(+), 42 deletions(-) diff --git a/src/content/lesson/what-is-dom-define-dom.md b/src/content/lesson/what-is-dom-define-dom.md index 422ebb406..958b589de 100644 --- a/src/content/lesson/what-is-dom-define-dom.md +++ b/src/content/lesson/what-is-dom-define-dom.md @@ -23,7 +23,7 @@ Thankfully, we have browsers! They let us render our application in a visual int As you already know, the responsibility of the browser is to transform HTML/CSS code into visual elements. Those elements are mapped into a hierarchy that is stored in RAM memory, and it’s called The DOM. -With JavaScript we can manipulate the DOM (website elements) during runtime (during the application's life cycle). +With JavaScript we can manipulate the DOM (website elements) during runtime (the application's lifecycle). NOTE: Please always remember that all JavaScript code that you write in your HTML document MUST be wrapped inside a ` ``` +Nowadays, we tend to write all of our JS code in a separate file with extension `.js`, in which case the script tag in your html's body needs to look like this: + +```html + +
some content
+
more content
+ + + +``` + +This is the preferred way for you to write and link your JS code from now on, as well. + ## How to Update Your Website DOM There are several ways to manipulate the DOM, but the most simple one is `document.write()`. Every time you create a `document.write()` you will be writing onto the HTML whatever string you decide to pass as a parameter to the *write* function. -It does not matter where you write the code. The only thing that matters is that it is wrapped inside a `