Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").eq(-2).css("background-color", "yellow");
});
</script>
</head>
<body>
<h1>Welcome to My Homepage</h1>
<p>My name is Donald.</p>
<p>Donald Duck.</p>
<p>I live in Duckburg (will be selected, because it is the 2nd element from the end of the selected elements).</p>
<p>My best friend is Mickey.</p>
</body>
<!-- Mirrored from www.w3schools.com/jquery/tryit.asp?filename=tryjquery_traversing_eq2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 15:43:27 GMT -->
</html>