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

143
Views
What dose mean by "window.scrollY > 0"
window.addEventListener("scroll",()=>{
const header = document.querySelector("header");
header.classList.toggle("sticky", window.scrollY > 0);
})

I know about .toggle() method but not so clearly. Would some one please explain about toggle() and window.scrollY?

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Scroll Down. scrollY property of the Window interface returns the number of pixels that the document is currently scrolled vertically.

window.addEventListener("scroll", (event) => {
  document.querySelector("h1").textContent = this.scrollY;
  document.querySelector("h2").textContent = ("sticky", window.scrollY > 0);
})
body {
  width: 100vw;
  height: 400vh;
}

h1 {
  position: fixed;
  top: 0;
}

h2 {
  position: fixed;
  top: 20%;
}
<h1>0</h1>
<h2></h2>

almost 4 years ago · Santiago Trujillo 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!