w3resource

jQuery: Using jQuery find all children of each division

jQuery Fundamental - II : Exercise-58

Using jQuery find all children of each division.

Sample solution :

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Using jQuery find all children of each div.</title>
</head>
<body>
<p>This is a paragraph.</p>
<div><p>This is a paragraph within a division.</p></div>
<p>Here is a another paragraph.</p>
<div>This is a <span>span</span> element within a division.</div>
</body>
</html>

JavaScript Code :

$( "div" ).children().css( "border-bottom", "3px double blue" );

See the Pen jquery-fundamental-exercise-58 by w3resource (@w3resource) on CodePen.


Contribute your code and comments through Disqus.

Previous: Write a program to places a border around all list items that are children of a specified class of an unordered list.
Next: Using jQuery find all children with a specified class of each division.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.