In my html i have got div with given class.
After clicking a button I would like to set the position to the top of that div. it may go the in smooth way .
How can I do that ?
thanks for help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yep, check this out: http://jsfiddle.net/AlienWebguy/JU3xj/5/
Essentially, we first create a small plugin called scrollTo:
Then, getting the html to scroll to that position in the DOM is very simple:
In that code,
300is the duration – the time it takes for the scroll to happen. The larger the number, the slower it goes. It’s in milliseconds, so 1000 would equal 1 second.linearis the easing. For other types of easing, I’d recommend including JQueryUI– have a look at their easing options.