Try it
Javascript
Jquery
Angular
Learn Angular
Learn Javascript
Learn Bootstrap
Learn jQuery
JQuery Child element
In this example The children() method returns all direct children of the selected element.
<!DOCTYPE html> <html> <head> <style> .descendants * { display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("ul").children().css({"color": "cyan", "border": "2px solid green"}); }); </script> </head> <body class="descendants">body will be great-grandparent <div style="width:700px;">div will grandparent <ul>ul will be direct parent <li>li will be child <span>span will be grandchild</span> </li> </ul> </div> </body> </html>
Output
×
Save This try
Title
Description
<p>In this example The children() method returns all direct children of the selected element.</p>