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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:47:22+00:00 2026-06-15T11:47:22+00:00

<a href=javascript:(void); id=lnkP>show all children</a> <a href=javascript:(void); id=lnkC1>hide child 1</a> <a href=javascript:(void); id=lnkC2>hide child

  • 0
<a href="javascript:(void);" id="lnkP">show all children</a>
<a href="javascript:(void);" id="lnkC1">hide child 1</a>
<a href="javascript:(void);" id="lnkC2">hide child 2</a>

<div id="p" style="display:none;">
<div id="c1">child 1</div>
<div id="c2">child 1</div>...
</div>​

$("#lnkP").click(function(){
    $("#p").children().show(); //seems there's a problem here...
});
$("#lnkC1").click(function(){
   $("#c1").hide(); 
});
$("#lnkC2").click(function(){
   $("#c2").hide(); 
});​

jsFiddle: http://jsfiddle.net/CBGsF/1/

What I am trying to do is:

  1. p is a parent container
  2. click show all children link, display
    all child divs under p
  3. click lnkC1 or lnkC2 to hide
    individual child div

But it seems that I didn’t get .children() working correctly. So how to fix it? Any ideas?

  • 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-15T11:47:23+00:00Added an answer on June 15, 2026 at 11:47 am

    Since the parent (#p in your case) has a display:none, it’s children won’t be visible.

    You’ll need to show the parent first,

    $("#p")
    .show()
    .children().show();
    

    (jQuery’s chaining, very helpful)

    Please try and get rid of the inline styling (it gets unmanageable after a while), use classes as much as possible.

    You can have a class in css,

    .displayNone
    {
        display: none;
    } 
    .displayBlock
    {
       display: block;
    }
    

    And then use jquery methods .removeClass(), .addClass() or .toggleClass() to show/hide your elements.

    This is just a recommendation 🙂

    Test link: http://jsfiddle.net/CBGsF/8/

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

Sidebar

Related Questions

I have this: <ul class=deposit style=float:left;list-style-type:none;> <a href=javascript:void(0) id=inc><li class=first>+</li></a> <a href=javascript:void(0) id=dec><li class=second>-</li></a>
<a id=a$id onclick=check($id,1) href=javascript:void(0) class=black>Qualify</a> After href is removed, is Qualify still clickable?
Using this jquery code: <a href=javascript:void(0) id=m1>Get Selected id's</a> jQuery(#m1).click( function() { var s;
PHP code: <a id=a$id onclick=check($id,1) href=javascript:void(0) class=black>Qualify</a> I want to remove the onclick=check($id,1) so
I have one function for one element: <a href=javascript:void(0); onclick=dothis()>Link</a> When this function is
I need to split this/similar string to get the VALUE <a href=javascript:void(0); id=def_ name=color
I know that in Javascript document.location.href = #my_id tells the browser to display the
I have this bookmarklet: javascript:void(window.open(document.links[Math.floor(Math.random()*document.links.length)].href,'_blank')) It outputs random link from a document full of
<a href="javascript:void(0)" id="loginlink">login</a> I've seen such href s many times, but I don't know
Possible Duplicates: Href for Javascript links: “#” or “javascript:void(0)”? Why is it bad practice

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.