John Smitth
John Smitth

Reputation: 127

jQuery wont show hidden children divs

Lets see this simple fiddle:

JFiddle

 <div id="a" style="display: none;">1
 <div style="display: none;">2
  <div style="display: none;">3
   <div style="display: none;">4</div>
  </div>
 </div>
</div>
$(document).ready(function()
              {
$('#a').show('fast');
              });

I want to see all 1 2 3 4 but instead I only see 1. How to tell to jQuery to show all nested items?

Upvotes: 0

Views: 87

Answers (3)

Tim B James
Tim B James

Reputation: 20364

In order to show all 4, just remove display: none; from the nested divs

<div id="a" style="display: none;">1
 <div>2
  <div>3
   <div>4</div>
  </div>
 </div>
</div>
$(document).ready(function()
              {
$('#a').show('fast');
              });

Upvotes: 1

Gaurav Pandey
Gaurav Pandey

Reputation: 2796

Try:

$(document).ready(function()
{
$('#a, #a div').show('fast');
});

Upvotes: 1

Billy Moon
Billy Moon

Reputation: 58601

You need to select all elements, not just the parent...

$('#a, #a div').show('fast');

Upvotes: 1

Related Questions