Can you review the code snippet below?
I need a function to trigger when the red box's top aligns with the viewport during scrolling.
JS Fiddle: http://jsfiddle.net/ay5ttmLk/
HTML
<div class="test" style="height:100px;width:70px;">
sadfsadf
saf
sadf
saf
s
af
saf
saf
sadf
sadfsafsafsaf
</div>
<div class="test" style="height:100px;width:70px;">
sadfsadf
saf
sadf
saf
s
af
saf
saf
sadf
sadfsafsafsaf
sadfsaf
sadfsafsadf
</div>
CSS
.test {margin-top: 500px;
margin-bottom: 1000px;
background-color: red;}
JS
var el = $('.test');
el.on('scroll', function(){
if(el.scrollTop() == 0){alert("hit the top")}
});