Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
issue related to fixing a header with HTML & JavaScript - help needed

I try to fix a header stycky with html & JavaScript but it doesn't work. Please find my code below.

<header>
    <a href="#" class="logo"><span>P</span>etits<span>S</span>oins</a>
    <ul class="navbar">
    <li><a href="#">Accueil</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Qui sommes nous</a></li>
    <li><a href="#">Contact</a></li>
    </ul>
</header>

<script type="text/javascript">
    window.addEventListener('scrol', function(){
      const header = document.querySelector('header');
      header.classList.toggle("sticky", window.scrollY > 0);
    });
 </script>


header.sticky{
   background: #fff;
padding: 10px 10px;
box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.05);
position: -webkit-sticky;/*Safari*/
position: sticky;
top: 0;
}
header.sticky .logo{
color: #000;
}
header.sticky .navbar li a{
color: #000;
}
header.sticky .navbar li a:hover{
color:#333;
border-bottom: 2px solid #333;
}

Could you please help me to find a solution so that it works?

Thankyou Andreea

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!