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

170
Views
ScrollTop Jquery Js

I want each time the user scrolls the page my header becomes black

Here is the function:

 $(windows).on('scroll', function(){
            if($(window).scrollTop()) {
                $('nav').addClass('scroll');
            }
            else {
                $('nav').removeClass('scroll');
            }
        });
header {
  width: 100%;
  height: 100vh;
  background-image: url("./assets/header.png");
  background-size: cover;
  background-position: center;
}

nav {
  position: fixed;
  width: 100%;
}

nav.scroll ul {
  background-color: #000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
        <nav id="header_frame">
            <div class="hamburger">
                <i class="fa-solid fa-bars"></i>
            </div>

            <div class="menu">
                <ul>
                    <li> <a href="#"> Le coté Lumineux </a> </li>
                    <li> <a href="#"> Le coté Obscur </a> </li>
                    <li> <a href="#"> L'empire </a> </li>
                    <li> <a href="#"> les Droïdes </a> </li>
                    <li> <a href="#"> Les Ewoks </a> </li>
                    <li> <a href="#"> Jabba Le Hutt </a> </li>
                </ul>
            </div>
        </nav>
    </header>

But it doesn't work,but an error message in the console : "index.html:100 Uncaught ReferenceError: windows is not defined at index.html:100:11"

Please i need help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is a syntax error in your code:

$(window).on('scroll', function(){});

not

$(windows).on('scroll', function(){});

jQuery global object window don't have "S" character.

about 4 years ago · Juan Pablo Isaza Report
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!