.children(selector)
In jquery .children() method allow us to search through the children of DOM element.This construct a new jQuery object from the matching elements.This method only travels a single level down the DOM tree.Here we are changing the <span> element color inside the <p> tag having para2 class using the method.
<div class="myclass"> <p class="para1">This is <span>first</span> element</p> <p class="para2"><span>Test1</span> Demo <span>Test2</span></p> <p class="para3">This is last element</p> </div>
Now we are using the jquery method.
$( "p.para2" ).children("<span>").css( "color", "red" );
.find(selector)
.find() method is used find element inside DOM element.It allows us to search through the descendants of these elements in the DOM tree and construct a new jQuery object from the matching elements.This method travels a multi level down the DOM tree.
Now here we are changing the color of text inside the span element using this method inside the DOM element.
<div class="myclass"> <p class="para1">This is <span>first</span> element</p> <p class="para2"><span>Test1</span> Demo <span>Test2</span></p> <p class="para3">This is last element</p> </div>
Now we are using the jquery method.
$( ".myclass" ).find( "<span>" ).css( "color", "red" );
After using this method you will see that all text inside the span become red color.
That’s all.