jQuery :nth-last-child() Selector

jQueryWeb DevelopmentFront End Technology

The :nth-last-child() selector in jQuery is used to select all elements that are the nth child, counting from the last child.


The syntax is as follows −


Above, the n parameter is the index of each child to match. The even parameter selects even child element, whereas odd selects odd child element.


Let us now see an example to implement the jQuery :nth-last-child() selector −

<!DOCTYPE html>
   .one {
      color: white;
      background-color: green;
      font-size: 16px;
      border: 2px blue solid;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<h1>Match Details</h1>
<div style="border:1px solid;">
<p>Date: 29th October 2019</p>
<p>Timings: 3PM TO 8PM</p>
<p>Ground: Lords</p>
<p> Entry begins 2PM</p>
<div style="border:1px solid;">
<p>Date: 29th October 2019</p>
<p>Timings: 8PM TO 11PM</p>
<p>Ground: Lords</p>


This will produce the following output −

Published on 05-Nov-2019 12:09:46