Jquery to page up after click button [closed]

1

Good morning, friends,

I'm looking for days by a "page up" function when the user clicks a button.

I only find "Add Back to Top" button options, but I do not want to add a button, I want the button to make the page go up. Type "select", and when the user selects the page goes up.

Does anyone know this type of function and can you point me to some material?

I was trying to do it this way ... haha

$document(onclick)function(){   
    $("[name='Selecionar']");
    window.scrollTo({
    top: 1000,
    behavior: "smooth"
});

Now:

<script>
$(document).ready(function() {
   $('.list_options.hotels .hotel_block .rooms_options > .price').click(function(event) {
        event.preventDefault();
        $('html, body').animate({scrollTop: 0}, 1000);
        event.stopPropagation();
    });
});
</script>
    
asked by anonymous 17.09.2018 / 15:38

1 answer

1

Gabriel from what we talked about in the comment field I think this is what you need.

If you already have access to the site's JS, and your project already has jQuery you just need to create an event for the btn class to when clicked back to the top of the page.

Follow the example, I left two btns, one above and one below, just click on them and go to the top of the page:

$(document).ready(function() {
    $('.price').click(function(event) {
        event.preventDefault();
        $('html, body').animate({scrollTop: 0}, 1200);
        event.stopPropagation();
    });
});
.price .purchase {
    background: #00b0cd;
    background-size: 15px;
    color: #fff;
    font-family: Roboto;
    font-weight: 600;
    text-transform: uppercase;
    padding: '';
    margin: '';
}
p {
    margin: 1000px auto;
}
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><pclass="price"><a href="#" class="purchase" title="Selecionar">Selecionar</a></p>
<p class="price"><a href="#" class="purchase" title="Selecionar">Selecionar</a></p>

   
    
17.09.2018 / 17:01