Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e6f57c

Browse files
authored
Update LESSONPLAN.md
1 parent 9b3a61f commit 0e6f57c

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

Week1/LESSONPLAN.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,69 @@ The purpose of this class is to introduce to the student:
1818

1919
FIRST HALF (12.00 - 13.30)
2020

21-
## 1. How a webpage is made up of objects (DOM)
21+
## 1. Document Object Model (DOM)
2222

2323
### Explanation
24+
The [Document Object Model (DOM)](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction) is an _object-oriented representation_ of a web page(HTML document) which the web browsers make available to JavaScript for manipulation. Inside a JavaScript file, we can access the DOM through a global object called `document` or `window.document`.
25+
26+
**It is not a programming language but without it JavaScript would not have any knowledge of our web page/HTML document.**
2427
### Example
28+
```HTML
29+
<!DOCTYPE html>
30+
<html>
31+
<head>
32+
<title>My title</title>
33+
</head>
34+
35+
<body>
36+
<h1>My header</h1>
37+
<a href="https://www.w3schools.com/js/pic_htmltree.gif">My link</a>
38+
</body>
39+
</html>
40+
```
41+
42+
![Pictorial Representation of DOM](https://www.w3schools.com/js/pic_htmltree.gif)
2543
### Exercise
2644
### Essence
2745

2846

29-
## 2. How JavaScript can be used to manipulate those objects (DOM manipulation)
47+
## 2. DOM manipulation
3048
### Explanation
3149
### Example
50+
1. Finding DOM elements in HTML page
51+
52+
- `document.getElementById(id)` - Find an element by element id
53+
- `document.getElementsByTagName(name)` - Find elements by tag name
54+
- `document.getElementsByClassName(name)` - Find elements by class name
55+
56+
2. Adding and Deleting elements in HTML page
57+
58+
- `document.createElement(element)` - Create a new HTML element
59+
- `document.removeChild(element)` - Remove an HTML element
60+
- `document.appendChild(element)` - Add an HTML element
61+
62+
3. Changing existing HTML elements
63+
64+
- `element.innerHTML` - Change the content/layout of the element
65+
- `element.innerText` - Change just the text of the element
66+
- `element.setAttribute(attribute, value)` - Set/Change attribute of an element
67+
68+
* Note: `getElementsByTagName` and `getElementsByClassName` returns a list of all matched elements. However, this is not the usual JavaScript array but an HTMLCollection List. A detailed list of APIs available on the DOM can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/Document).
3269
### Exercise
70+
1. Create an HTML form element
71+
2. Create an HTML input(type text) element and set its placeholder as "First Name"
72+
3. Create another HTML input(type text) element and set its placeholder as "Last Name"
73+
4. Add both these elements to the form element
74+
5. Create a button element and add these properties to it:
75+
76+
a. Set its text to "Click Me"
77+
78+
b. Set its id to "button"
79+
80+
c. Set its type to "button"
81+
82+
6. Add button element to the form
83+
7. Add the form element to main element
3384
### Essence
3485

3586
SECOND HALF (14.00 - 16.00)

0 commit comments

Comments
 (0)