Display DIV and then go to an element inside that DIV
<p>I am currently trying to unhide a DIV and then right after scroll down to an element.</p>

<p>I have this "index" of text where I have a list of anchor tags href'ing to different ID's down the page, but at first sight the text is hidden and will first display when you click on one of the index links. All this works fine untill I get to the scroll part.</p>

<p>There is nothing special about the code so far, it's just a mere if statement adding &amp; removing a CSS class depending on the client action. But how do I get the page to automatically scroll down after the DIV displays?</p>

<p>I tried this solution: <a href="http://stackoverflow.com/questions/4801655/how-to-go-to-specific-to-element-on-page">How to go to specific to element on page</a>, but I couldn't seem to fit it in my own script.</p>

<pre><code>if ($('#&lt;%=paragraph.ClientID%&gt;').hasClass("readable")) {
     $('#&lt;%=paragraph.ClientID%&gt;').removeClass("readable"); // Readable is the class that hides the paragraphs.
     // Run function to scroll down to selected element here.
}
else {
     $('#&lt;%=paragraph.ClientID%&gt;').addClass("readable");
}
</code></pre>

<p>What I first tried was something like this:</p>

<pre><code>(function($) {
        $.fn.goTo = function() {
            $('html, body').animate({
                scrollTop: $(this).offset().top + 'px'
            }, 'fast');
            return this; // for chaining...
        }
    })(jQuery);

    function showParagraphs(elementId) {
        if ($('#&lt;%=paragraph.ClientID%&gt;').hasClass("readable")) {
            $('#&lt;%=paragraph.ClientID%&gt;').removeClass("readable");
            scrollToElement(elementId);
        }
        else {
            $('#&lt;%=paragraph.ClientID%&gt;').addClass("readable");
        }
    };

    function scrollToElement(elementId) {
        $(elementId).goTo();
    };
</code></pre>

<p>But the above script didn't work. And my javascript skills a limited, so I'm kind of lost.</p>

<p>Any hints or help would be awesome. Thank you.</p>
