Hi,
I am using slideDown() and slideUp() in an accordian style menu to reveal and conceal sections of the menu. By default it seems that these methods will open and close from the top or bottom respectively.
Is there a way to use the methods so that the bottom of the element seems to be being pulled down or pushed up rather than simply revealed or concealed?
I hope this makes sense. Any help would be greatly appreciated.
There are styling elements added dynamically to wrap each heading and section which is why they have containers and why the iteration through parents() is necessary.
- <div id="accordian">
- <div class="accordian-button-container">
- <div id="content-home" class="accordian-button">Home</div>
- </div>
- <div class="accordian-heading-container">
- <div class="accordian-heading">
- About
- </div>
- </div>
- <div class="accordian-section-container">
- <ul class="accordian-section">
- <li id="dialog-about-author">The Author</li>
- <li id="dialog-about-website">The Website</li>
- </ul>
- </div>
- <div class="accordian-heading-container">
- <div class="accordian-heading">
- Themes
- </div>
- </div>
- <div class="accordian-section-container">
- <ul class="accordian-section">
- <li id="style-square-flat">Square Flat</li>
- <li id="style-square-glass">Square Glass</li>
- <li id="style-round-flat">Round Flat</li>
- <li id="style-round-glass">Round Glass</li>
- </ul>
- </div>
- <div class="accordian-heading-container">
- <div class="accordian-heading">
- Media
- </div>
- </div>
- <div class="accordian-section-container">
- <ul class="accordian-section">
- <li id="content-image-viewer">Image Viewer</li>
- <li id="content-music-player">Music Player</li>
- <li id="content-video-player">Video Player</li>
- </ul>
- </div>
- </div>
- $('.accordian-heading').each(function () {
- $(this).addClass('outset');
- $(this).addClass('highlightable');
- $(this).click(function () {
- $(this).parents().each(function () {
- if ($(this).attr('class') === 'accordian-heading-container') {
- $(this).next().slideDown('slow');
- $(this).addClass('expanded');
- }
- else if ($(this).attr('class') === 'accordian-heading-container expanded') {
- $(this).next().slideUp('slow');
- $(this).removeClass('expanded');
- }
- });
- });
- });