Javascript examples for jQuery Method and Property:last
Select last span inside p 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 w w w .j a v a 2 s .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>