Accordion w/ auto-scroll

Accordion w/ auto-scroll

So I have a site that implements the Accordion ui plugin ( http://docs.jquery.com/UI/Accordion).

Everything works well but the client wanted the active accordion to always scroll to the top of the browser.

This turned out to be really simple.  I just took the "bind method" code and added an animate method.

         $('.ui-accordion').bind('accordionchange', function(event, ui) {
            ui.newHeader // jQuery object, activated header
            ui.oldHeader // jQuery object, previous header
            ui.newContent // jQuery object, activated content
            ui.oldContent // jQuery object, previous content
            
            $('html, body').animate({scrollTop: $(ui.newHeader).offset().top}, 1);
            
        });

Cheers!