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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:19:05+00:00 2026-05-28T18:19:05+00:00

I have a simple hide show jquery script I grabbed from an example site.

  • 0

I have a simple hide show jquery script I grabbed from an example site. I am trying to traverse through using $(this). to target the divs I want to hide/show. I have been able to make this work for the first goruping, anything after the first fails. I have tinkered with the code so I have a few examples of failure below to help decern what it is I am trying to do. Here is the code.

<script type="text/javascript">
//$(document).ready(function(){
//  $("#hide").click(function(){
//    $(this).('#hideShowParent > #hideShow').hide();
//  });
//  $("#show").click(function(){
//    $(this).('#hideShowParent > #hideShow').show();
//  });
//});
$(document).ready(function(){
$("#hide").click(function(){
    $(this).find().parent("#hideShowParent").sibling("#hideShow").hide();
});
$("#show").click(function(){
    $(this).find().parent("#hideShowParent").sibling("#hideShow").hide();
}); 
});
</script>

now i am looping over something that may have one or two or more. I would like for my jQuery to target the parent of the clicked button, find the sibling div called hideShow in the closest proximity below and hide or show (could use toggle too.

<div id="hideShowParent">
<ul>
<li>
    <button id="show">Show</button> 
    - <button id="hide">Hide</button> 
    <b>Medium</b>
        <div id="hideShow">

                <table>
                    <tr>
                        <td><hr /></td>
                    </tr>            
                    <tr><td height="15px">somethingn textual</td></tr>
                    <tr>
                        <td><hr /></td>
                    </tr>
                </table> 

        </div>
</li>
</ul>
</div>
<div id="hideShowParent">
<ul>
<li>
    <button id="show">Show</button> 
    - <button id="hide">Hide</button> 
    <b>Medium</b>
        <div id="hideShow">

                <table>
                    <tr>
                        <td><hr /></td>
                    </tr>            
                    <tr><td height="15px">somethingn textual</td></tr>
                    <tr>
                        <td><hr /></td>
                    </tr>
                </table> 

        </div>
</li>
</ul>
</div>

Thanks in advance for the help. I hope all this make sense.

  • 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-28T18:19:06+00:00Added an answer on May 28, 2026 at 6:19 pm

    Firstly you should use the id attribute in that way – ID’s should be unique. So i would replace them with the class attribute which can be the same on multiple DOM elements :

    <div class="hideShowParent">
    <ul>
    <li>
        <button class="show">Show</button> 
        - <button class="hide">Hide</button> 
        <b>Medium</b>
            <div class="hideShow">
    
                    <table>
                        <tr>
                            <td><hr /></td>
                        </tr>            
                        <tr><td height="15px">somethingn textual</td></tr>
                        <tr>
                            <td><hr /></td>
                        </tr>
                    </table> 
    
            </div>
    </li>
    </ul>
    </div>
    <div class="hideShowParent">
    <ul>
    <li>
        <button class="show">Show</button> 
        - <button class="hide">Hide</button> 
        <b>Medium</b>
            <div class="hideShow">
    
                    <table>
                        <tr>
                            <td><hr /></td>
                        </tr>            
                        <tr><td height="15px">somethingn textual</td></tr>
                        <tr>
                            <td><hr /></td>
                        </tr>
                    </table> 
    
            </div>
    </li>
    </ul>
    </div>
    

    The following code would then work :

    $(document).ready(function() {
        $(".hide").click(function() {
            $(this).siblings(".hideShow").hide();
        });
        $(".show").click(function() {
            $(this).siblings(".hideShow").show();
        });
    });
    

    Working example : http://jsfiddle.net/MztAm/

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

Sidebar

Related Questions

I have a simple show/hide jquery script that works fine on its own, The
I have a simple script to hide/show a table row. I'd like it to
I have some simple jQuery toggle script like this: <script type=text/javascript> $(document).ready(function() { $('#clickedit').click(function()
I have some very simple jQuery hide/show logic called on a change in select
This is regarding the following jQuery plugin: http://blog.danawoodman.com/jquery-showhide/ I am using jQuery show hide
I have a simple unordered list that I want to show and hide on
I have a simple file that has a Jquery script it in that looks
Made a simple script that hide/show a hidden div. The page automatically adjusts its
i have simple regular expression: ^123$ Matches are for example 123 1234 etc. How
I have simple SSIS package which reads data from flat file and insert into

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.