Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function () { $("button").click(function () { alert('No of li: ' + $("ul").children().length); }); }); </script> </head> <body> <h1>jQuery DOM Traversing Methods: children()</h1> <ul> <li>List 1</li> <li>List 2</li> <li>List 3</li> <li>List 4</li> <li>List 5</li> </ul> <button>Click Here to Test .children()</button> </body> </html>
Result: