Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to make the site scrollable?

Hi everyone,

How do you make the buttons highlight when you scroll down? Can anyone help me with that? Thanks. https://w.trhou.se/x9ni77uy7k

1 Answer

You're need to use the scroll event listener

// listen to scrolling changes on window
$(window).scroll(function(e) {
  // check it's scrolled down, anything higher than 0 is true
  if (window.scrollY > 0) {
     // do your magic
    $("menu a").addClass("scrolled")
  }
})