parent child
RUN
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>first-of-type demo</title> <style> .active { border: solid 1px red; font-size: 120%; margin: 10px; font-style: italic; } </style> <script src="https://code.jquery.com/jquery-2.0.0.js"></script> </head> <body> <ul id="contain"> <li>Item 1</li> <li>Item 2 <ul> <li>Nested item 1</li> <li>Nested item 2</li> <li>Nested item 3</li> </ul> </li> <li>Item 3</li> </ul> <script> $("#contain > li").addClass('active'); </script> </body> </html>
PHÓNG TO