views:

74

answers:

1

I'm trying to toggle an element based on the viewport and scrolling.

By using $(window).scroll(function().. I can fire an event when the user scrolls but how do I check whether you're scrolled to the top in order to hide the element?

A: 

In IE the property is

document.body.scrollTop 

and in standards-based browsers the property is

window.pageYOffset

Test for a value of 0 to hide your element.

Robusto
Perfect, just what I needed. Thanks.Found an article on the subject here as well: http://radumicu.info/blog/2010/02/20/animated-top-link-that-works-on-every-browser/
Oskar Rough