Javascript examples for jQuery:Selector
$("ul li:first-child") Selects the first <li> element of every <ul>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("ul li:first-child").hide(); });/* w ww . j a v a 2s.co m*/ }); </script> </head> <body> <p>List 1:</p> <ul> <li>A</li> <li>B</li> <li>Tea</li> </ul> <p>List 2:</p> <ul> <li>A</li> <li>B</li> <li>Tea</li> </ul> <button>Click me</button> </body> </html>