<!DOCTYPE html>
<html>
<head>
<title>jQuery :nth-last-child(n) Selector</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("p:nth-last-child(2)").css('color', 'red');
});
</script>
</head>
<body>
<section style="border:1px solid #000;">
<p>first paragraph contents...</p>
<p>second paragraph contents..</p>
<p>third paragraph contents...</p>
</section>
<br />
<h1>Article heading</h1>
<p>second paragraph contents.</p>
<p>last 2<sup>nd</sup> element of parent <body> element.</p>
<div style="border:1px solid #000;">
<h3>Footer Ending</h3>
<p>first paragraph contents...</p>
<p>second paragraph contents..</p>
</div>
</body>
</html>