JQuery: children, find and has

In the jQuery, we always need determine if the a certain element existed in current object, you can use $(this).children, $(this).find(), and $(this).has(). What’s different between these 3 methods?

The .children() only travels a single level down the DOM tree, that means it’s only search son level, not grand-sons level. .find() and .has() travels down all levels to select descendant elements, but .find() can filtered by a selector, jQuery object, or element, .has() only can check a selector, but .has() will construct a new jQuery object from a subset of the matching elements.

Here is just summary of these 3 methodes, More details and examples see:

http://api.jquery.com/children/, http://api.jquery.com/find/ and http://api.jquery.com/has/

 

 

Advertisements

About qianggan

Sr. Software Engineer
This entry was posted in Uncategorized. Bookmark the permalink.

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