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

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
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 */
    .first {
    width: 100%;
    height: 1000px;
    background: #ccc;

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

/*Downloaded from */
    $(".export-btn").click(function() {
        scrollTop: $("#drop1").offset().top},

<script async src="//,html,css,result/dark/"></script>