@@ -14,7 +14,6 @@ const InitializeDateCountDown = () => {
1414
1515 if ( ! isDateValid ( countDownDate ) ) return ;
1616
17- // Update the count down every 1 second
1817 var x = setInterval ( function ( ) {
1918
2019 // Get today's date and time
@@ -29,17 +28,18 @@ const InitializeDateCountDown = () => {
2928 document . getElementById ( "demo" ) . innerHTML = "EXPIRED" ;
3029 }
3130
32- const _targetYear = document . querySelector ( '[wt-datecount-element="target-year"]' ) ;
33- const _targetMonth = document . querySelector ( '[wt-datecount-element="target-month"]' ) ;
34- const _targetDay = document . querySelector ( '[wt-datecount-element="target-day"]' ) ;
35- const _targetHour = document . querySelector ( '[wt-datecount-element="target-hour"]' ) ;
36- const _targetMin = document . querySelector ( '[wt-datecount-element="target-minute"]' ) ;
37- const _targetSec = document . querySelector ( '[wt-datecount-element="target-second"]' ) ;
31+ const _targetYear = document . querySelector ( '[wt-datecount-element="target-year"]' ) ;
32+ const _targetMonth = document . querySelector ( '[wt-datecount-element="target-month"]' ) ;
33+ const _targetDay = document . querySelector ( '[wt-datecount-element="target-day"]' ) ;
34+ const _targetHour = document . querySelector ( '[wt-datecount-element="target-hour"]' ) ;
35+ const _targetMin = document . querySelector ( '[wt-datecount-element="target-minute"]' ) ;
36+ const _targetSec = document . querySelector ( '[wt-datecount-element="target-second"]' ) ;
3837
3938 // Time calculations for days, hours, minutes and seconds
4039 var year = Math . floor ( distance / ( 1000 * 60 * 60 * 24 ) ) ;
4140 var month = Math . floor ( distance / ( 1000 * 60 * 60 * 24 ) ) ;
4241 var days = Math . floor ( distance / ( 1000 * 60 * 60 * 24 ) ) ;
42+
4343 var hours = Math . floor ( ( distance % ( 1000 * 60 * 60 * 24 ) ) / ( 1000 * 60 * 60 ) ) ;
4444 var minutes = Math . floor ( ( distance % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ) ;
4545 var seconds = Math . floor ( ( distance % ( 1000 * 60 ) ) / 1000 ) ;
@@ -53,3 +53,5 @@ const InitializeDateCountDown = () => {
5353
5454 } , 1000 ) ;
5555}
56+
57+ window . addEventListener ( 'DOMContentLoaded' , InitializeDateCountDown ( ) ) ;
0 commit comments