Select nth Last Element of Its Type $(":nth-last-of-type(n)")

$(":nth-last-of-type(n)")

e.g. $("div:nth-last-of-type(n)") n:{integer e.g. [1,2,...,n], even, odd or equation e.g. (n+2) n= [0,1,...,n] }

$(":nth-last-of-type(n)") selects elements that are the nth of their types within their parents starting from the last.

$(":nth-of-type(1)") is equivalent to $(":first-of-type")
Example 1: $("li:nth-last-of-type(2)") will select all <li> elements that are 2nd elements of type <li> within their parents starting from the last.
<ul>
<li>1st</li> 
<li>2nd</li> // 2nd of type <li> 
<li>3rd</li> // 1st of type <li> 
</ul>
    
<ul>
<li>1st</li> // 2nd of type <li> 
<li>2nd</li> // 1st of type <li> 
</ul>
Example 2: $("li:nth-last-of-type(odd)") will select all <li> elements that are odd <li> elements within their parents starting from the last.
<ul>
<li>1st</li> // 3rd of type <li>, 3 is ODD 
<li>2nd</li> // 2nd of type <li>, but 2 is EVEN 
<li>3rd</li> // 1st of type <li>, 1 is ODD
</ul>
    
<ul>
<li>1st</li> // 2nd of type <li>, why not selected? 
<li>2nd</li> // 1st of type <li>, 1 is ODD 
</ul>
Example 3: $("li:nth-last-of-type(n+2)") will select all <li> elements that are (n+2) <li> elements within their parents starting from the last.
Notice: for equation, n starts from zero
<ul>
<li>1rd</li> // 3rd of type <li>, (1+2)=3 
<li>2nd</li> // 2nd of type <li>,(0+2)=2 
<li>3st</li>
</ul>
    
<ul>
<li>1nd</li> // 2nd of type <li>, (0+2)=2 
<li>2st</li>
</ul>
Example 4: $(".d:nth-last-of-type(2)") will find all 2nd elements of their types with class='d' within their parents starting from the last.
<div>
  <p>a</p>
  <span class="d">b</span>  //2nd <span> with class='d'
  <span>c</span> //1st <span> within its parent <div>
</div>

<div>
  <p class="d">d</p>  //2nd <p> with class='d'
  <span class="d">e</span>  //2nd <span> with class='d'
  <p>f</p>  //1st <p> within its parent <div>
  <span>g</span> //1st <span> within its parent 
</div>
jQuery selector filter $(":nth-last-of-type(n)")