Scrollto element with an id selector using jQuery

For example, if I have a button with an id “btn” and a form with the id “form” and I want to scrollto the form when I click on the button


<p><a href="" id="btn">go to form</a></p>

<form id="form">





            $('html, body').animate({
                scrollTop: $("#form").offset().top
            }, 1000);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s