Andrew
Andrew

Reputation: 3999

Show all elements within div?

My code looks like this:

<div id="div1">
      <span id="span1"></span>
      <span id="span2"></span>
      <span id="span3"></span>
</div>

I used these jquery commands:
$('#span1').hide()
$('#span2').hide()


Now I want to unhide all the elements within div1.

How can I do that? Thanks for the help!

Upvotes: 2

Views: 9797

Answers (3)

Dave Robertson
Dave Robertson

Reputation: 383

$('#div1 span').show();

or whole document

$('span').show();

Upvotes: 0

emco
emco

Reputation: 4719

Try this:

$('span[id*="span"]').show();

Upvotes: 0

icchanobot
icchanobot

Reputation: 3343

You could do this:

$('div#div1 span').show();

Which would show each span inside the div with id='div1'.

Or, if the div contains things which aren't spans, you can use:

$('div#div1').children().show();

Upvotes: 8

Related Questions