File tree Expand file tree Collapse file tree 18 files changed +334
-100
lines changed Expand file tree Collapse file tree 18 files changed +334
-100
lines changed Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
4
< title > So Many Kale Recipes</ title >
6
5
</ head >
7
6
< body >
@@ -13,11 +12,5 @@ <h1>Above and Beyond the Kale of Duty</h1>
13
12
Do you love to cook with < a href ="kale.html "> kale</ a > ?
14
13
</ p >
15
14
</ main >
16
- < script >
17
- const bodyLinks = document . querySelectorAll ( 'a' ) ;
18
- bodyLinks . forEach ( kid => {
19
- console . log ( kid ) ;
20
- } )
21
- </ script >
22
15
</ body >
23
16
</ html >
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > So Many Kale Recipes</ title >
6
+ </ head >
7
+ < body >
8
+ < header id ="page-banner ">
9
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
10
+ </ header >
11
+ < main id ="page-content ">
12
+ < p >
13
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
14
+ </ p >
15
+ </ main >
16
+ < script >
17
+ const bodyLinks = document . querySelectorAll ( 'a' ) ;
18
+ bodyLinks . forEach ( kid => {
19
+ console . log ( kid ) ;
20
+ } )
21
+ </ script >
22
+ </ body >
23
+ </ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Adding a class to an element</ title >
4
+ < title > So Many Kale Recipes</ title >
6
5
</ head >
7
- < style >
8
- .my-class {
9
- display : flex;
10
- justify-content : center;
11
- align-items : center;
12
- border : 6px dotted black;
13
- font-family : Verdana, serif;
14
- font-size : 2rem ;
15
- background-color : lightgray;
16
- }
17
- </ style >
18
6
< body >
19
- < div id ="my-div ">
20
- Hello World!
21
- </ div >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
22
15
< script >
23
- document . getElementById ( 'my-div' ) . classList . add ( 'my-class' ) ;
16
+ const content = document . getElementById ( "page-content" ) ;
17
+ const firstContentChildNode = content . firstChild ;
18
+ console . log ( firstContentChildNode ) ;
24
19
</ script >
25
20
</ body >
26
21
</ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Tweaking HTML Attributes with JavaScript</ title >
4
+ < title > So Many Kale Recipes</ title >
6
5
</ head >
7
6
< body >
8
- < header >
9
- < img id ="header-image "
10
- src ="mangosteen.png "
11
- alt ="Drawing of a mangosteen ">
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
12
9
</ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
13
15
< script >
14
- const headerImage = document . getElementById ( 'header-image' ) ;
15
- console . log ( headerImage . id ) ;
16
- console . log ( headerImage . src ) ;
17
- console . log ( headerImage . alt ) ;
16
+ const content = document . getElementById ( "page-content" ) ;
17
+ const firstContentChildElement = content . firstElementChild ;
18
+ console . log ( firstContentChildElement ) ;
18
19
</ script >
19
20
</ body >
20
21
</ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Setting up an event handler</ title >
4
+ < title > So Many Kale Recipes</ title >
6
5
</ head >
7
6
< body >
8
- < div id ="my-div "> </ div >
9
- < button id ="my-button "> Click to add some text, above</ button >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
10
15
< script >
11
- const myButton = document . getElementById ( 'my-button' ) ;
12
- myButton . addEventListener ( 'click' , function ( ) {
13
- const myDiv = document . getElementById ( 'my-div' ) ;
14
- myDiv . innerHTML = '<h1>Hello Click World!</h1>' ;
15
- } ) ;
16
+ const para = document . querySelector ( "main > p" ) ;
17
+ const lastParaChildNode = para . lastChild ;
18
+ console . log ( lastParaChildNode ) ;
16
19
</ script >
17
20
</ body >
18
21
</ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Running code after the web page document is fully loaded</ title >
6
- < script >
7
- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
8
- console . log ( 'We are loaded!' ) ;
9
- } ) ;
10
- </ script >
4
+ < title > So Many Kale Recipes</ title >
11
5
</ head >
12
6
< body >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
15
+ < script >
16
+ const para = document . querySelector ( "main > p" ) ;
17
+ const lastParaChildElement = para . lastElementChild ;
18
+ console . log ( lastParaChildElement ) ;
19
+ </ script >
13
20
</ body >
14
21
</ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Getting data about the event</ title >
6
- < style >
7
- body {
8
- margin : 1em ;
9
- font-size : 1.5em ;
10
- }
11
- div {
12
- margin-top : .5em ;
13
- }
14
- </ style >
4
+ < title > So Many Kale Recipes</ title >
15
5
</ head >
16
6
< body >
17
- < div >
18
- Type a key:
19
- </ div >
20
- < input id ="key-input " type ="text ">
21
- < div >
22
- Here's the code of the key you pressed:
23
- </ div >
24
- < div id ="key-output ">
25
- </ div >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
26
15
< script >
27
- const keyInput = document . getElementById ( 'key-input' ) ;
28
- keyInput . addEventListener ( 'keypress' , function ( e ) {
29
- const keyOutput = document . getElementById ( 'key-output' ) ;
30
- keyOutput . innerHTML = e . which ;
31
- } ) ;
16
+ const childElement = document . querySelector ( "h1" ) ;
17
+ const parentElement = childElement . parentNode ;
18
+ console . log ( parentElement ) ;
32
19
</ script >
33
20
</ body >
34
21
</ html >
Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
5
- < title > Preventing the default event action</ title >
6
- < style >
7
- body {
8
- margin : 1em ;
9
- font-size : 1.5em ;
10
- }
11
- div {
12
- margin-top : .5em ;
13
- }
14
- </ style >
4
+ < title > So Many Kale Recipes</ title >
15
5
</ head >
16
6
< body >
17
- < a href ="https://wiley.com/ "> Wiley</ a > < br >
18
- < a href ="https://262.ecma-international.org/6.0/ "> ECMAScript 2015 Spec</ a > < br >
19
- < a href ="https://webdev.mcfedries.com/tools/workbench/ "> WebDev Workbench</ a >
20
- < div id ="output ">
21
- Link URL:
22
- < div >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
23
15
< script >
24
- const links = document . getElementsByTagName ( 'a' )
25
- for ( const link of links ) {
26
- link . addEventListener ( 'click' , function ( e ) {
27
- e . preventDefault ( ) ;
28
- strURL = e . target . href ;
29
- document . getElementById ( 'output' ) . innerHTML = 'Link URL: ' + strURL ;
30
- } )
31
- }
16
+ const currElement = document . querySelector ( "main" ) ;
17
+ const prevSib = currElement . previousElementSibling ;
18
+ console . log ( prevSib ) ;
32
19
</ script >
33
20
</ body >
34
21
</ html >
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < title > So Many Kale Recipes</ title >
5
+ </ head >
6
+ < body >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
15
+ < script >
16
+ const currElement = document . querySelector ( "header" ) ;
17
+ const nextSib = currElement . nextElementSibling ;
18
+ console . log ( nextSib ) ;
19
+ </ script >
20
+ </ body >
21
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < title > So Many Kale Recipes</ title >
5
+ </ head >
6
+ < body >
7
+ < header id ="page-banner ">
8
+ < h1 > Above and Beyond the Kale of Duty</ h1 >
9
+ </ header >
10
+ < main id ="page-content ">
11
+ < p >
12
+ Do you love to cook with < a href ="kale.html "> kale</ a > ?
13
+ </ p >
14
+ </ main >
15
+ < script >
16
+ const newArticle = document . createElement ( "article" ) ;
17
+ document . querySelector ( "main" ) . append ( newArticle ) ;
18
+ newArticle . innerHTML = "<h2>Article</h2>" ;
19
+
20
+ const newNav = document . createElement ( "nav" ) ;
21
+ document . querySelector ( "main" ) . prepend ( newNav ) ;
22
+ newNav . innerHTML = "<h2>Navigation</h2>" ;
23
+ </ script >
24
+ </ body >
25
+ </ html >
You can’t perform that action at this time.
0 commit comments