.children() methodThe .children(selector) method in jQuery is used to create a new jQuery object that contains the children nodes of each matched elements,not including the comment and text nodes,optionally filtered by a selector
.children() method Syntax.children([selector])
.children() method ExampleFind out all the children of each paragraph and wrap them with a bold tag.
HTML
<p>Hello<span id="brand">Lautturi</span></p>
jQuery
$('p').children();
$('p').children().wrap( "<b></b>" );
Result
[<span id="brand">Lautturi</span>] <b><span id="brand">Lautturi</span></b>
.children(selector) method ExampleFind all children with a class "selected" of each div.
HTML
<div>
<p>java tutorial</p>
<p>learn javascript</p>
<p class="selected">learn jquery</p>
<p>python tutorial</p>
<p class="selected">PHP</p>
</div>
jQuery
$("div").children(".selected")
Result
[<p class="selected">learn jquery</p>,<p class="selected">PHP</p>]
