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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:45:58+00:00 2026-05-13T22:45:58+00:00

Why this two functions have the strange behaviour of when I click on thead,

  • 0

Why this two functions have the strange behaviour of when I click on thead, the tbody expands and then collapse.

On the second function could do some testing adding alerts to the if, else statement but it only gets into the if statement so it would only slideUP.

Another thing I notice is that when there is only one row in tbody it works fine. Why?

I have also tried to add return false, and nothing, the function it is not called twice or on any other place.

I would appreciate if I could get some fix for this.

Thanks.

Function 1
$(function() {
    $("table.section thead").click(function() {
    $(this).next("table.section tbody").slideToggle("slow");

    });
});

Function 2
$(function() {
    $("table.section thead").click(function() {
      var body = $(this).next("table.section tbody");
      if (body.is(":visible"))
         body.slideUp("slow");
      else
         body.slideDown("slow");
    });
});

UPDATE
Table

<table>
<thead>
<tr><td>heading></td></tr>
</thead>
<tbody>
<tr><td>content1</td></tr>
<tr><td>content2</td></tr>
</tbody>
</table>
  • 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-13T22:45:58+00:00Added an answer on May 13, 2026 at 10:45 pm

    I looked at the jQuery mailing lists, this is highly browser dependent since they treat tables and how they block completely differently. Instead I’d try to have the head in a different element and slide the whole table, or instead, fade the body, something like this:

    $(function() {
      $("table.section thead").click(function() {
        $(this).next("tbody").animate({opacity: 'toggle'});
      });
    });
    

    Dynamically adjusting the dimensions on individual table components and having it be cross-browser correctly seems to be not worth it to fix in he jQuery framework, so I wouldn’t expect this to change any time soon.

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

Sidebar

Related Questions

Suppose I have two functions which look like this: public static void myFunction1(int a,
I have got two pages. example.com/php.com and example.com. I use this function to set
This are my two functions, on single click it works fine, but on dblclick
I'm witnessing some strange behaviour from Fluent nHibernate. I have two objects involved in
I have a strange behaviour with the code below: function update(txt, _) { #text
I'm using two functions one is from this site http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ and its using function
I've tried this two ways. Way 1 function Login() { var email = encodeURIComponent($(#loginemail).val());
I use this script in two different servers: function curlGetFileInfo($url, $cookies=default){ global $_config; $ch
I want this function (defn ret-lowest-str-len Computes the lengths of two strings. Returns default
This question is regarding getopt function in php. I need to pass two parameter

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.