Scroll to top

by Vishnu Prasad

HTML

<h1>YES</h1>

<article style="height: 1000px">
    <p>test</p>
</article>

CSS

h1{margin-top:100px;}

JavaScript

$(document).ready(function () {

    $(window).scroll(function () {
        if ($(this).scrollTop() > 100) { 
            //change yes to no
            $('h1').html('No');
        } else {
            //set h1 text to yes
            $('h1').html('Yes');
        }
    });
});