Element.scrollTop - what Im a doing wrong

Element.scrollTop - what Im a doing wrong

I'm new to jQuery so this may be a stupid question, but why doesnt my code work? I'm trying to do something when the user scrolls down the page.

  1. $(window).scroll(function () {
                    var w = $(window).scrollTop;

                    if (w > 10) {
                        alert("test");
                    }
                });