Javascript examples for jQuery Method and Property:last
The last() method returns the last element of the selected elements.
The following code shows how to Select the last <p> element inside the last <div> element:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p span").last().css("background-color", "yellow"); });//from www .j a va 2s . c o m </script> </head> <body> <p>My <span>name</span> is span.</p> <p>tutorial from <span>java2s.com</span>.</p> <p>tutorial from <span><b>java2s.com</b></span>.</p> </body> </html>