简体   繁体   中英

Jquery Show & ScrollTop (or ScrollTo)

Just as the topic says I'm trying to get a link to open a hidden div then scroll to it. I have the first part taken care of. As for the scrollTop or ScrollTo function I've been trying to use the ScrollTo plugin and for an unknown reason it's not working.

First of all does this look correct?

<li>
    <a href="#" rel="toggle[kov]" title="$.scrollTo('div#kov', 500);">
        Sara Kovanda
    </a>

Then later down the page

<section class="container" id="kov">

I'm using the dynamic drive script, http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm For the first part since after hours of looking I cannot find a jquery plugin that allows for multiple divs that show on click and hides any current div that's open.

Any help would be extremely helpful here.

Simple example, no plugins:

http://jsfiddle.net/wr2sj/2/

$("#a").click(function() {
    $('html, body').animate({
        scrollTop: $("#b").offset().top
    });
    return false;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM