I have a pricey area, and I have a button next to "have more details", I want that when clicking this button, the screen scroll down the page that is where I have the "contact" section. I wanted to know how to do this "slip"
I have a pricey area, and I have a button next to "have more details", I want that when clicking this button, the screen scroll down the page that is where I have the "contact" section. I wanted to know how to do this "slip"
Use anchors:
poe this on the button:
<a href="#anchor">botão</a>
And where do you want to go, you poe:
<a name="anchor"></a>
If you want the screen to slide with animation, you can use jquery animate .
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#anchor").offset().top
}, 2000);
});
Do not use the name
attribute, this is deprecated in the latest version of HTML, and J. Guilherme's answer may not work in newer browsers. Use id
:
<div id='meuelemento'> <!-- ... --> </div>
And no <a>
:
<a href='#meuelemento'> <!-- ... --> </a>