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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:05:12+00:00 2026-06-09T19:05:12+00:00

I have a jQuery function I wrote which will slideToggle an additional table row.

  • 0

I have a jQuery function I wrote which will slideToggle an additional table row. There is a cell at the end of the clickable row that contains a button, however as the click of a container div triggers the function, clicking anywhere in the row will cause the new row to expand.

I need the function to only be triggered when the button is clicked as there is scope to add checkboxes, links etc to other parts of the table.

Code:

    var toggleSpeed = 600;
    var expandText = "more";
    var collapseText = "less";
$(".extrainfo_container").click(function() {
       $(this).find('.extrainfo').slideToggle(toggleSpeed);
        if ($(this).find('.moreless').text() == collapseText) {
                $(this).find('.moreless').text(expandText)
        }
        else {
        $(this).find('.moreless').text(collapseText);
    }
    });  




<table>   
     <tr>
        <td>Header 1</td>
        <td>Header 2</td>
        <td>Header 3</td>
    </tr>
</table>
<div class="extrainfo_container">
    <table>   
         <tr>
            <td>Col 1</td>
            <td>Col 2</td>
            <td><div class="moreless">more</div></td>
        </tr>
        <tr>
            <td colspan="3">
                <div class="extrainfo">
                    Extra information.<p />
                    Extra information.<p />
                </div>
            </td>
        </tr>
    </table>
</div>

Working example: http://jsfiddle.net/E22XR/69/

I have searched the forums, and although I did find similar questions and answers, none of them worked for me. I figure there must be something different I am doing, and/or there is a better way to achive the same result – I am quite new to writing my own functions.

If there is a better way, a requirement is that I do not use IDs as there could be any number of rows created dynamically.

  • 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-06-09T19:05:14+00:00Added an answer on June 9, 2026 at 7:05 pm

    You could do this I guess.

     var toggleSpeed = 600;
        var expandText = "more";
        var collapseText = "less";
    $(".moreless").click(function() {
           $(".extrainfo_container").find('.extrainfo').slideToggle(toggleSpeed);
            if ($(".extrainfo_container").find('.moreless').text() == collapseText) {
                    $(".extrainfo_container").find('.moreless').text(expandText)
            }
            else {
            $(".extrainfo_container").find('.moreless').text(collapseText);
        }
        }); 
    

    Edit : Hack for multiples rows

    var toggleSpeed = 600;
    var expandText = "more";
    var collapseText = "less";
    $(".moreless").click(function () {
       var detailsRow = $(this).parent().parent().next();
       detailsRow.find('.extrainfo').slideToggle(toggleSpeed);
       if ($(this).text() == collapseText)
          $(this).text(expandText);
       else
          $(this).text(collapseText);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a jquery function that will be activated when any checkbox
I've got a Jquery function that I wrote which blacks out the screen after
I've got a Jquery function that I wrote which blacks out the screen after
I have this jquery function that works, except I need to add something. I
I have a jQuery function that replaces thumbnails with the main image. This is
I have a jQuery function - this is the response that is it is
Here's the story... I have a jQuery function that does something, this function is
I have the following jquery function that submits to an iframe. The message sent
I have a jQuery cycle script (which I wrote, so it's not high quality)
I'm trying to write a replacewith function in jQuery that will replace specific words

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.