Javascript examples for jQuery Selector:nth-child
Select Last child with element inside
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(window).load(function(){/* w w w . j ava2 s .co m*/ $(function() { $('p:has(span)').last().css({ 'background': 'red' }); }); }); </script> </head> <body> <div> <p> <span>asdf</span> </p> <p> <span>aaa</span> </p> <p>aaa</p> </div> </body> </html>