jQuery Selector parent > child select <li> under <ul> with specific class
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("ul.test > li").css("border", "4px double"); });//w w w .j a va 2s.co m </script> </head> <body> <ul class="test"> <li>List item</li> <li>List item <ul> <li>Nested list item</li> </ul> </li> <li>List item</li> </ul> </body> </html>