<div id="myElement" style="position: absolute">
This stays at the top
</div>
$(window).scroll(function() {
$('#myElement').css('top', $(this).scrollTop() + "px");
});
<div id="myElement" style="position: absolute">
This stays at the top
</div>
$(window).scroll(function() {
$('#myElement').css('top', $(this).scrollTop() + "px");
});