Hi Everone, welcome to my blog and in this blog post i will share the code of JavaScript practice project "Fringe Salon" for beginners along with explaination. You can copy the code by clicking the button just above the code. Read the explaiantion for better understanding.
let's get started with index.html file:
index.html
style.css:
index.js:
Here is the explaination:
Sticky Header: When the user scrolls on the webpage, the code checks the vertical scroll position (window.scrollY). If the scroll position is greater than 0, it adds the CSS class "sticky" to the header element. Otherwise, it removes the "sticky" class. This allows the header to stick to the top of the viewport when the user scrolls down.
Countdown Timer: The code initializes a countdown timer by setting the countDownDate variable to a specific date and time in the future. It then uses setInterval to run a function every second. Inside this function, it calculates the remaining time (distance) between the current time and the countDownDate. It then breaks down the remaining time into days, hours, minutes, and seconds. The calculated values are displayed on the webpage using document.getElementById("demo").innerHTML. If the distance becomes less than 0, indicating that the countdown has expired, the interval is cleared, and the text "EXPIRED" is displayed.
FINAL WORDS:
Thank you Don't forget to leave your feedback in the comment section. Follow front.end24 on instagram for more project ideas
index.html
style.css:
index.js:
Here is the explaination:
Sticky Header: When the user scrolls on the webpage, the code checks the vertical scroll position (window.scrollY). If the scroll position is greater than 0, it adds the CSS class "sticky" to the header element. Otherwise, it removes the "sticky" class. This allows the header to stick to the top of the viewport when the user scrolls down.
Countdown Timer: The code initializes a countdown timer by setting the countDownDate variable to a specific date and time in the future. It then uses setInterval to run a function every second. Inside this function, it calculates the remaining time (distance) between the current time and the countDownDate. It then breaks down the remaining time into days, hours, minutes, and seconds. The calculated values are displayed on the webpage using document.getElementById("demo").innerHTML. If the distance becomes less than 0, indicating that the countdown has expired, the interval is cleared, and the text "EXPIRED" is displayed.
FINAL WORDS:
Thank you Don't forget to leave your feedback in the comment section. Follow front.end24 on instagram for more project ideas

Comments
Post a Comment