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 499525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:59:40+00:00 2026-05-13T05:59:40+00:00

I’m just learning jQuery, figuring out what’s possible, finding my way around. I’d like

  • 0

I’m just learning jQuery, figuring out what’s possible, finding my way around.

I’d like to have a div “slide out” like an accordion, but I don’t want to pay the cost of the jQuery UI download, and also I want to allow multiple divs to be open at the same time.

How does it work? How is the slide-out effect of the accordion done, inside jquery.ui.accordion.js? Is there a call I can make to .animate() to move a div from display:none to display:block ? (I read that animate works only with numeric properties.)

  • 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-13T05:59:40+00:00Added an answer on May 13, 2026 at 5:59 am

    I’m learning all sorts of things. I used jQuery only – no UI, no UI Accordion, no UI Effects – and got the slide-down effect that I wanted. Not sure of the terminology for this visual effect. (I think that is half the challenge with jQuery – what do I call the various effects). I think maybe some people call this “toggle blinds”.

    Click this to see the effect: http://jsbin.com/ogape

    Here’s the html fragment

    <div id="div0">
       <p id="intro"><a href="#" class='expander'>+</a> Introduction</p>
    
       <div class='indented' style='display:none'>
         <p >
           Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer
           vulputate, nibh non rhoncus euismod, erat odio pellentesque lacus,
           sit amet convallis mi augue et odio. Phasellus cursus urna facilisis quam.
         </p>
    
         <p> Quisque pharetra lacus quis sapien. Duis
           id est non wisi sagittis adipiscing. Nulla facilisi. Etiam quam erat,
           lobortis eu, facilisis nec, blandit hendrerit, metus. Fusce
           hendrerit. Nunc magna libero, sollicitudin non, vulputate non, ornare
           id, nulla.  Suspendisse potenti. Nullam in mauris.
         </p>
       </div>
     </div>
    

    This is the jQuery code:

      var slideOut = function(element){
          var parent = $(element).parent().parent(); // outer div
          var dList = parent.children("div");  // inner div, all siblings of the <a>
          dList.animate({opacity: 'toggle', height: 'toggle'}, 'slow');
      };
    
      $(document).ready(function() {
          $('div p a[href="#"]').click(function() { slideOut(this); });
      });
    

    That slideOut() function is slightly simplified from what it actually does. It also swaps the + and – for the expander button in the actual code, which makes it a little more complicated:

      var slideOut = function(element){
          var parent = $(element).parent().parent(); // outer div
          var dList = parent.children("div");  // inner div, all siblings of the <a>
          dList.animate({opacity: 'toggle', height: 'toggle'}, 'slow');
    
          // swap characters on the expander "button"
          var o = dList.css("opacity"); 
          // dash is narrower than +, so we must compensate
          if (o==1) {
              $(element).html("+")
                  .css("padding-left", "1px")
                  .css("padding-right", "1px");
          } else {
              $(element).html("-")
                  .css("padding-left", "3px")
                  .css("padding-right", "3px");
          }
      };
    

    You can see the full html/js code at the live demo link referenced above.

    The key thing that I did not know, is that one can animate the height by calling animate with “toggle”.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a JSP page retrieving data and when single or double quotes are
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm looking for suggestions for debugging... If you view this site in Firefox or
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

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.