File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 1111 < div class ="clock-face ">
1212 < div class ="hand hour-hand "> </ div >
1313 < div class ="hand min-hand "> </ div >
14- < div class ="hand second-hand " style ="
15- transform: rotate(-50deg); "> </ div >
14+ < div class ="hand second-hand "> </ div >
1615 </ div >
1716 </ div >
1817
7675 </ style >
7776
7877 < script >
78+ const secondHand = document . querySelector ( '.second-hand' ) ;
79+ const hourHand = document . querySelector ( '.hour-hand' ) ;
80+ const minuteHand = document . querySelector ( '.min-hand' ) ;
81+
82+ function setDate ( ) {
83+ const now = new Date ( ) ;
84+ const seconds = now . getSeconds ( ) ;
85+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
86+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
87+
88+ const mins = now . getMinutes ( ) ;
89+ const minsDegrees = ( ( mins / 60 ) * 360 ) + 90 ;
90+ minuteHand . style . transform = `rotate(${ minsDegrees } deg)`
91+
92+ const hour = now . getHours ( ) ;
93+ const hourDegrees = ( ( hour / 12 ) * 360 ) + 90 ;
94+ hourHand . style . transform = `rotate(${ hourDegrees } deg)`
95+ console . log ( seconds ) ;
96+ }
97+
98+ setInterval ( setDate , 1000 ) ;
7999 </ script >
80100</ body >
81101</ html >
You can’t perform that action at this time.
0 commit comments