Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 973937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:21:22+00:00 2026-05-16T03:21:22+00:00

I am using .slideToggle to open a panel when the user clicks a link:

  • 0

I am using .slideToggle to open a panel when the user clicks a link:

<script type="text/javascript"> 
$(document).ready(function(){
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); 

return false;
});
});
</script> 

The content of the toggled div (#panel) is taller than the height of the containing div so scorllbars show up. I would like the vertical scrollbar to automatically scroll down to the reveal the new content when the div gets toggled. I think I could probably do this with .scrollTop to make this happen but Im not sure how to go about making it happen at the same time… Any ideas?

EDIT:
There seems to be a consensus that this is the best way to go about achieving what I described:

<script type="text/javascript">
$(document).ready(function(){
    $(".btn-slide").click(function(){
        var $panel = $("#panel");
        $panel.slideToggle("slow");
        if ($panel.is(':visible')){
            $panel.parent().scrollTop($panel.height()-$panel.parent().height());
        }
        $(this).toggleClass("active"); 

        return false;
    });
});
</script>

This makes the panel slide but the scroll down effect isn’t working..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:21:23+00:00Added an answer on May 16, 2026 at 3:21 am

    I’ve done something like this before:

       $(".btn-slide").click(function(event){
    
        if ( $(this).hasClass("active"))
        {
             $(this).removeClass("active");
             $("#panel").slideUp("slow");
        }
        else
        {
             $(this).addClass("active");
             $("#panel").slideDown("slow");
    
             var destination = $("#container ").offset().top + $("#container").height();
    
    
             $("#container").animate({ scrollTop: destination},"slow");
             //or
             //$("#container").animate({ scrollTop: destination},"slow", "fx_name_here");
    
        }
    
    
        event.preventDefault();
    });
    

    Html:

    <a href="#" class="btn-slide">Fire Panel</a>
    <div id="container">
        <div id="panel">sdfsdfsdfs</div>
    </div>
    

    Would that help you?

    EDIT:

    If you download the jQuery Easing Plugin you can add different effects to the sliding, adding the fx name into the code (commented out line in answer)

    Improved code so there is less code but same effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone tell me why this doesn't work: $(document).ready(function() { $(#cookie).text(expanded); //panel toggle $(.btn-slide).click(function()
I am using slidetoggle to open and close div, with easing using jquery. <script>
I'm using this jQuery to hide a DIV: $(#slider).click(function() { $(.help).slideToggle(); $(#wrapper).animate({ opacity: 1.0
I am using toggleClass and slideToggle to accomplish the following: when the user selects
I am using the following sliding div script: http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html Currently, the slidetoggle function is
I'm using jquerys slideToggle method and would like to add a callback function that
I'm using Soh Tanaka's script to toggle open and closed div content in the
I have a div of which collapse and expands using slideToggle and easing. $('button').click(function
I'm trying to use jQuery's slideToggle function to show or hide a panel which
I have a set of nested DIVs that slidetoggle using jQuery as the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.