You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By now you are very familiar function declaration, expression function, arrow function and anonymous function. In this challenge we tend to use array function instead of other functions. Arrow function is not a replacement for other functions. In addition, arrow functions and function declarations are not exactly the same. So you should know when to use and when not. I will cover the difference in detail in other sections. We will use explicit return instead of implicit return if the function is one liner
140
+
By now you are very familiar function declaration, expression function, arrow function and anonymous function. In this challenge we tend to use arrow function instead of other functions. Arrow function is not a replacement for other functions. In addition, arrow functions and function declarations are not exactly the same. So you should know when to use and when not. I will cover the difference in detail in other sections. We will use explicit return instead of implicit return if the function is one liner
141
141
142
142
```js
143
143
// function which prints full name of a person
@@ -182,7 +182,7 @@ const showDateTime = () => {
182
182
183
183
#### Loops
184
184
185
-
We coverer many types of loops in this challenges. The regular fo loop, while loop, do while loop, for of loop, forEach loop and for in loop.
185
+
We coverer many types of loops in this challenges. The regular for loop, while loop, do while loop, for of loop, forEach loop and for in loop.
Copy file name to clipboardExpand all lines: 21_Day/21_day_dom.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ We can access already created element or elements using JavaScript. To access or
59
59
<!DOCTYPE html>
60
60
<html>
61
61
<head>
62
-
<title>Document Object Model/title>
62
+
<title>Document Object Model</title>
63
63
</head>
64
64
<body>
65
65
@@ -133,15 +133,15 @@ The _document.querySelector_ method can select an HTML or HTML elements by tag n
133
133
**_querySelector_**: can be used to select HTML element by its tag name, id or class. If the tag name is used it selects only the first element.
134
134
135
135
```js
136
-
let firstTitle =document.querySelect('h1') // select the first available h2 element
136
+
let firstTitle =document.querySelector('h1') // select the first available h2 element
137
137
let firstTitle =document.querySelector('#first-title') // select id with first-title
138
138
let firstTitle =document.querySelector('.title') // select the first available h2 element with class title
139
139
```
140
140
141
141
**_querySelectorAll_**: can be used to select html element by its tag name or class. It return a nodeList which is an array like object which support array methods. We can use **_for loop_** or **_forEach_** to loop through each nodeList elements.
142
142
143
143
```js
144
-
constallTitles=document.querySelectAll('h1')
144
+
constallTitles=document.querySelectorAll('h1')
145
145
146
146
console.log(allTitles.length) // 4
147
147
for (let i =0; i <allTitles.length; i++) {
@@ -299,7 +299,7 @@ Let us add some style to our titles. If the element has even index we give it gr
299
299
```js
300
300
consttitles=document.querySelectorAll('h1')
301
301
titles.forEach((title, i) => {
302
-
title.fontSize='24px'// all titles will have 24px font size
302
+
title.style.fontSize='24px'// all titles will have 24px font size
303
303
if (i %2===0) {
304
304
title.style.color='green'
305
305
} else {
@@ -315,7 +315,7 @@ Let us add some style to our titles. If the element has even index we give it gr
315
315
```js
316
316
consttitles=document.querySelectorAll('h1')
317
317
titles.forEach((title, i) => {
318
-
title.fontSize='24px'// all titles will have 24px font size
318
+
title.style.fontSize='24px'// all titles will have 24px font size
319
319
if (i %2===0) {
320
320
title.style.backgroundColor='green'
321
321
} else {
@@ -331,7 +331,7 @@ Let us add some style to our titles. If the element has even index we give it 20
331
331
```js
332
332
consttitles=document.querySelectorAll('h1')
333
333
titles.forEach((title, i) => {
334
-
title.fontSize='24px'// all titles will have 24px font size
334
+
title.style.fontSize='24px'// all titles will have 24px font size
Copy file name to clipboardExpand all lines: 22_Day/22_day_dom_day_2.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,7 @@ To see a created element on the HTML document we should append it to the parent
115
115
title =document.createElement('h1')
116
116
title.className='title'
117
117
title.style.fontSize='24px'
118
+
title.textContent= i
118
119
document.body.appendChild(title)
119
120
}
120
121
</script>
@@ -219,7 +220,7 @@ The above snippet of code cleared all the child elements.
219
220
220
221
### Exercises: Level 3
221
222
222
-
Check the requirement of this project from both images(jpg and gif). All the data and CSS has been implemented using JavaScript only. The data is found on starter folder project_3.
223
+
Check the requirement of this project from both images(jpg and gif). All the data and CSS has been implemented using JavaScript only. The data is found on starter folder project_3. The drop down button has been created using [*details*](https://www.w3schools.com/tags/tag_details.asp) HTML element.
0 commit comments