Select Last Matching Element .last()

.last()

e.g. $("div").last()

$("selector").last() selects last element in the matched set.

Example 1: $("div").last() will first find all <div> then select last matching element i.e. last div.
<p>p-1</p>
<div id='someID'>div-1</div>
<div class='someClass'>div-2</div>
<div>div-3</div>
<span>span-1</span>
Matched set is a set of elements matching selector. For example, in Example 1 matchted set is set of elements matching $("div") selector
<p>p-1</p>
<div id='someID'>div-1</div> //index = 0
<div class='someClass'>div-2</div> //index = 1
<div>div-3</div> //index = 2
<span>span-1</span>
jQuery traversing filtering .last()