Tom Rider
Tom Rider

Reputation: 2805

how to access child element in jquery?

I want to access all the subelelements of a given element . For ex :

<div id="main">
  <div id="1">
   <span></span>
   <span></span>
  </div>
  <span></span>
  <div></div>      
 </div>

Like in abover structure #main contains 5 elements ( 2 div and 3 span ). How can i access it all in a single query ?

Upvotes: 0

Views: 169

Answers (3)

Bogdan
Bogdan

Reputation: 44526

Use this:

$('#main').find('*');

Upvotes: 1

Karl Laurentius Roos
Karl Laurentius Roos

Reputation: 4399

All you need is a wildcard selector, like this:

$("#main *")

Upvotes: 2

Ram
Ram

Reputation: 144659

You can use universal selector.

$('#main *')

Upvotes: 2

Related Questions