This tutorial will target a navbar element on the page and change both background color and text color when the user scroll 100px from top of the page.
Functions Used:
- The window.scroll Function to capture the scroll event whenever user scrolls.
- The scrollNavbar function is used to declare what happen whenever user scrolls
What you will find in the scrollNavbar Function:
- if statement to check the condition whether the user scrolls up to 100px
- Changed the background color of the navbar upon scroll
- forloop to add and remove color on links
A tech career with instinctHub
Ready to kickstart your tech career or enhance your existing knowledge? Contact us today for a dedicated instructor experience that will accelerate your learning and empower you to excel in the world of technology.
Our expert instructors are here to guide you every step of the way and help you achieve your goals. Don't miss out on this opportunity to unlock your full potential. Get in touch with us now and embark on an exciting journey towards a successful tech career.