File tree Expand file tree Collapse file tree
Week1/Homework/js-exercises Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //Changing Font
12document . body . style . fontFamily = "Arial,sans-serif" ;
3+ //Adding personal info
24document . querySelector ( "#nickname" ) . innerHTML = "Stef" ;
35document . querySelector ( "#fav-food" ) . innerHTML = "Pastitsio" ;
46document . querySelector ( "#hometown" ) . innerHTML = "New Philadelphia" ;
5-
7+ //Adding class in each li inside the ul
68let listItem = document . getElementsByTagName ( "li" ) ;
79for ( let i = 0 ; i < listItem . length ; i ++ ) {
810 listItem [ i ] . className = "list-item"
9- }
11+ }
12+ //Adding Photo
13+ let myPhoto = document . createElement ( "img" ) ;
14+ myPhoto . src = "https://media-exp1.licdn.com/dms/image/C5603AQH-4xn8lqwm_A/profile-displayphoto-shrink_200_200/0?e=1586390400&v=beta&t=cdHKfe_B5JDWPC76dV4BqGO1uUhKCzQk6ISv99lTYcY" ;
15+ document . body . appendChild ( myPhoto ) ;
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+
4+ < head >
5+ < meta charset ="utf-8 " />
6+ < title > Cat Walk</ title >
7+ </ head >
8+
9+ < body >
10+ < img style ="position:absolute; " src ="http://www.anniemation.com/clip_art/images/cat-walk.gif " />
11+ < script src ="catWalk.js "> </ script >
12+ </ body >
13+
14+ </ html >
Original file line number Diff line number Diff line change 1+ 'use strict'
2+ let catImage = document . querySelector ( "img" ) ;
3+ let positionNum = 10
4+ let positionStyle = catImage . style . left = positionNum + "px" ;
5+ let screenWidth = window . innerWidth ;
6+
7+ setInterval ( function ( ) {
8+ positionNum += 10 ;
9+ catImage . style . left = positionNum + "px" ;
10+ if ( positionNum === screenWidth / 2 ) {
11+ catImage . src = "https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif?itemid=10561424" ;
12+ }
13+ else if ( positionNum === screenWidth ) {
14+ positionNum = 10 ;
15+ catImage . src = "http://www.anniemation.com/clip_art/images/cat-walk.gif"
16+ }
17+
18+ } , 60 )
19+
Original file line number Diff line number Diff line change 1+ "use strict"
2+ function hijackGoogleLogo ( ) {
3+ let oldLogo = document . getElementById ( "hplogo" ) ;
4+ oldLogo . src = "https://www.hackyourfuture.dk/static/logo-dark.svg" ;
5+ oldLogo . srcset = "https://www.hackyourfuture.dk/static/logo-dark.svg" ;
6+ }
7+ hijackGoogleLogo ( ) ;
Original file line number Diff line number Diff line change 1+ "use strict"
2+ //Create an h1 that contains the time
3+ let h1 = document . createElement ( "h1" ) ;
4+ h1 . style . fontSize = ( "5rem" ) ;
5+ h1 . style . textAlign = ( "center" ) ;
6+ document . body . appendChild ( h1 ) ;
7+
8+ //Function to show the current time
9+ function currentTime ( ) {
10+ setInterval ( function ( ) {
11+ let today = new Date ( ) ;
12+ let time = `${ today . getHours ( ) } :${ today . getMinutes ( ) } :${ today . getSeconds ( ) } ` ;
13+ h1 . innerHTML = time ;
14+ } , 1000 ) ;
15+ }
16+ //Function onload
17+ h1 . onload = currentTime ( ) ;
18+
19+
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+
3+ < head >
4+ < title > Current time</ title >
5+ </ head >
6+
7+ < body >
8+ < script src ="showCurrentTime.js "> </ script >
9+ </ body >
10+
11+ </ html>
You can’t perform that action at this time.
0 commit comments