Select Last Matching Element .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.
<div id='someID'>div-1</div>
<div class='someClass'>div-2</div>
Matched set is a set of elements matching selector. For example, in Example 1 matchted set is set of elements matching $("div") selector
<div id='someID'>div-1</div> //index = 0
<div class='someClass'>div-2</div> //index = 1
<div>div-3</div> //index = 2
jQuery traversing filtering .last()