PruitIgoe
PruitIgoe

Reputation: 6384

jquery: scrollTop - scroll all divs within container div

I'm probably over thinking this:

I have the following set up:

<div id='wrapper'>
    <div id='container'>
        <div id='titlebar'><p class='clickObj'>Title</p></div>
        <div id='content' style='display: none;'>...stuff</div>
    </div>

    <div id='container'>
        <div id='titlebar'><p class='clickObj'>Title</p></div>
        <div id='content' style='display: none;'>...stuff</div>
    </div>

    <div id='container'>
        <div id='titlebar'><p class='clickObj'>Title</p></div>
        <div id='content' style='display: none;'>...stuff</div>
    </div>

    <div id='container'>
        <div id='titlebar'><p class='clickObj'>Title</p></div>
        <div id='content' style='display: none;'>...stuff</div>
    </div>


</div>

When you click on the title in clickObj, the associated content div's slides down. I then want the parent container to slide to the top of the wrapper div, pushing or pulling the other container divs with it. Hopefully that made sense.

I looked at scrollTo but wasn't sure how to use it for something like this.

Upvotes: 0

Views: 578

Answers (1)

Mark Broadhurst
Mark Broadhurst

Reputation: 2695

    $(".clickObj").click(function() {
        $(window).scrollTo($(this).offset().left, $(this).offset().top);
    });

Somthing like this ? (using Jquery)

Upvotes: 0

Related Questions