Click to scroll up

In this example below you will see how to do a Click to scroll up with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by jainulhuq, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright jainulhuq ©
  • HTML
  • CSS
  • JavaScript
    <div class="first"><button class="export-btn" type="button">Click Me!</button></div>
<div class="second" id="drop1">Hi</div>

/*Downloaded from https://www.codeseek.co/jainulhuq/click-to-scroll-up-MvQbee */
    .first {
    width: 100%;
    height: 1000px;
    background: #ccc;
}

.second {
    width: 100%;
    height: 1000px;
    background: #999;
}


/*Downloaded from https://www.codeseek.co/jainulhuq/click-to-scroll-up-MvQbee */
    $(".export-btn").click(function() {
    $('html,body').animate({
        scrollTop: $("#drop1").offset().top},
        'slow');
});

/*
<script async src="//jsfiddle.net/thepeanut/ohhffte6/embed/js,html,css,result/dark/"></script>
*/

Comments