How to correctly add the .scrollTo plugin?

I have this script, running on a links list:

$('li#linkcat-25 a').bind('click', function (e) {
    e.preventDefault();
    $('#preview').load($(this).attr('href'));
    $('#loading').show('fast');
    $('#preview').hide('fast');
    $('#preview').show('fast');
    $('#loading').hide('fast');
});

How can I easly add a .scrollTo effect, so that clicking on one of those href elements will show/hide as proposed, and when finished, will smoothly scroll down to the #preview div?

Thank you!

Answers


You most likely want the scrollTo plugin which can be used like this:

$('li#linkcat-25 a').click( function (e) {
    e.preventDefault();
    // any hiding or showing can be done here
    $.scrollTo( $("#preview") );
})

You can also provide the scrollTo plugin with a number of other useful options. Info can be found on the scrollTo plugin page but the link to the demo might have moved here.


Hi already mentioned it in a previous question.

You could put those elements in a div and then use .animate to scroll. like

$("#divcontainer").animate({'scrollTop': '600'}, 4000);

Need Your Help

SSAS Reporting Services - Set specific language / translation

sql-server sql-server-2005 sql-server-2008 reporting-services ssas

in the data warehouse there's a default language for the measures, and I added a translation for German captions. In a Visual Studio Report Server project, when creating a query with my German OS, ...

How do I upgrade my Amazon Elastic Beanstalk MySQL RDS instance to 5.6?

mysql amazon-web-services amazon-rds amazon-ebs

AWS provides guidelines as to how to upgrade a MySQL 5.5 instance to MySQL 5.6 using read replicas. However, its final step is to point your application to the new database, but EBS provides no