Skip to content

Commit 1872fb3

Browse files
Added today's content
1 parent 676967c commit 1872fb3

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

01_31_2023/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Document</title>
5+
<script src="script.js" defer></script>
6+
</head>
7+
<body>
8+
<div>
9+
<p style="color: blue">This is a paragraph</p>
10+
<p class="magenta">
11+
<span>This is a paragraph</span>
12+
</p>
13+
<p id="larger">This is a paragraph</p>
14+
<p class="magenta">This is a paragraph</p>
15+
<p>This is a paragraph</p>
16+
</div>
17+
</body>
18+
</html>

01_31_2023/review.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// objects
2+
const person = {
3+
name: "orlando c",
4+
age: 39,
5+
"-address": "jersey city",
6+
};
7+
8+
const keyToLookFor = "name";
9+
10+
// modifying a value of a key
11+
person.age = 29 // 😉 orlando's visible age
12+
13+
console.log(person.name);
14+
console.log(person.age);
15+
16+
// the following code is invalid
17+
// console.log(person.-address)
18+
19+
// alternative syntax
20+
console.log(person["name"]);
21+
console.log(person["age"]);
22+
23+
// this code however is valid
24+
console.log(person["-address"]);
25+
console.log(person[keyToLookFor]);
26+
27+
// looping thru object
28+
for (const property in person) {
29+
console.log("Property -> ", property, ", value -> ", person[property]);
30+
}

01_31_2023/script.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// to select one element, returns an HTMLElement
2+
const firstP = document.querySelector("p");
3+
4+
// to select all elements, returns a NodeList
5+
const paragraphs = document.querySelectorAll("p");
6+
7+
// modify a style property
8+
firstP.style.color = "red";
9+
10+
// display the content of paragraphs
11+
console.log(paragraphs);
12+
13+
// create elements
14+
const newParagraph1 = document.createElement("p");
15+
const newParagraph2 = document.createElement("p");
16+
17+
// when you create elements, they are not placed within the DOM
18+
// yet
19+
20+
// modify the text inside the element
21+
newParagraph1.textContent = "This is the last p";
22+
23+
// this code would add the new paragraph to the end of the body
24+
// document.body.appendChild(newParagraph1);
25+
26+
// select the first div on the document
27+
const div = document.querySelector("div");
28+
29+
// adds new paragraph to beginning of the div to
30+
div.prepend(newParagraph2);
31+
32+
// selects an element with id of larger
33+
const largerP = document.querySelector("p#larger");
34+
35+
// modifies the paragraph with the new font size
36+
largerP.style.fontSize = "2em";

01_31_2023/style.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
p {
2+
color: black;
3+
}

0 commit comments

Comments
 (0)