JQuery element’s Children


To get each level children even at lower level use .find()

To get first level children excluding text nodes use .children()

To get first level children including text nodes use .contents()


.find(selector)

Returns children, grand-children, grand-grand-children etc.  It return all children of any level of specified element. Looks for children in each and every level.

.children(selector)

Only looks for children only at first level if children available at that level it will show that otherwise it will show nothing

.contents()

It does not expect any argument. It is similar to .children() but it also returns text nodes.

So from above specified methods you can choose anyone according to your requirements.

 

Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in JQuery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: