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

  • SEARCH
  • Home
  • 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 7673119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:26:18+00:00 2026-05-31T16:26:18+00:00

I am trying to do a simple jQuery slideToggle() on a DIV containing text

  • 0

I am trying to do a simple jQuery slideToggle() on a DIV containing text and have found the animation to be very sluggish (seems to hesitate) as the slideDown animation nears the bottom of the sliding DIV.

Code and example of this may be found here. I have tested on several computers and all modern versions of the popular browsers, all behave the same way. Strangely, when I run the exact same page in jsFiddle, it is smooth.

Any ideas?

UPDATE

Part of this seems to be, like someone else suggested, that jQuery does not know the height of the sliding DIV before the animation runs. Since the content in the sliding DIV will be dynamic and either very short or somewhat long, neither do I. So, I tried grabbing the height of the DIV prior to hiding it with jQuery and then setting the CSS height accordingly. Made for a somewhat smoother animation but probably not the best solution – demo

UPDATE 2

It would appear that the problem was due to several CSS issues with the initial example. First, way too many DIVs. Second, the sliding DIV had padding set – does not play well
with toggleSlide, and finally, the sliding DIV was in a container DIV that also contained the #control-container (button) DIV.

Reducing the DIVs down to two (outer DIV for the sliding element and the sliding DIV itself) and not setting the outer sliding DIV padding seemed to do the trick – final example.

  • 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-31T16:26:19+00:00Added an answer on May 31, 2026 at 4:26 pm

    Blatant Karmaw***g just in case I’m on the right track 😉


    I’m on My iPhone right now so I can’t verify my assumption – but I have encountered similar quirks before when animating elements with padding and/or margin properties and height:auto.

    jQuery seems to have a hard time determining the actual height before animating under these circumstances.

    Try wrapping your actual content into a container div and/or giving it a fixed height to see whether the animation runs smoothly then.


    Edit 1:

    Another workaround I remember using:

    • Do not hide the element via CSS
    • On domready, determine element’s height via jQuery and assign it to the element via data(), then set element’s height to 0 and overflow:hidden
    • Instead of slideToggle(), use animate() with the height saved before.

    Fugly, but does the trick.


    Edit 2:

    A related issue (and a workaround) are described here


    Edit 3:

    Does this fiddle work for you, by any chance? Added Container with padding – excuse the bad formatting, jsfiddle’s no fun on the iPhone.

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

Sidebar

Related Questions

I'm trying to do a simple task with jQuery: I have a list of
Have some simple jquery that Im trying to execute on a button click. For
I have been trying to use a simple jQuery operation to dynamically match and
I'm trying to make a simple JQuery button from a div which will change
I'm trying to create a very simple jQuery slider; however, to get started, I
I'm trying a simple jQuery script to fadeout one div and fadein another one
I am trying to create a simple JQuery Div Slider, but it doesn't seem
I have a very simple div with an image inside: <div class=stack4> <img src=images/002m.jpg
I am trying to get simple jQuery to execute on my Content page with
I'm trying to build a simple jquery plugin that can take selectors as parameters.

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.