Home  >  jQuery

Example of .children() in jQuery

April 28, 2013
.children() in jQuery selects all the child DOM element and on those selection other jQuery function can be applied. .children() is called on parent DOM element but it applies only on children elements. Syntax is
Here parent is div element. Find the example.

<!DOCTYPE html>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<div>Inside first div, no other DOM element</div>
<div>Inside second div <span>span element</span></div>
<div>Inside second div <i>i element</i> and <b>b element</b> </div>
<script>$("div").children().css("color", "blue");</script>

Inside first div, no other DOM element
Inside second div span element
Inside second div i element and b element

©2021 concretepage.com | Privacy Policy | Contact Us