I want something to happen when you scroll to a certain point, is this possible?

I saw the scroll() function, but im not sure thats what i want?

Example: I have a nav bar at the top and i want to lower the opacity until it goes to a certain point (when the menu and banner dissapears), then the opacity goes back to 100%.

Thanks