Select Last Child Elements $(":last-child")

$(":last-child")

e.g. $("span:last-child")

$(":last-child") selects elements if they are last child of their parents.

Example 1: $("li:last-child") will select all <li> elements if they are last child of their parents.
<ul>
<li>1st</li>
<li>2nd</li>
</ul>
    
<ul>
<li>1st</li>
<li>2nd</li>
</ul>
Example 2: $("span:last-child") will find all <span> elements if they are last child of their parents.
<div>
  <span>a</span> 
  <span>b</span>
  <span>c</span>
</div>
<div>
  <span>d</span>
  <span>e</span>
  <p>f</p> // last child but not <span> 
</div>
jQuery selector filter $(":last-child")