Javascript examples for jQuery Method and Property:eq
Get second last 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").eq(-2).css("background-color", "yellow"); });//from ww w . ja v a 2s. c o m </script> </head> <body> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> <p>test</p> </body> </html>