How can i select the third div from bottom (i.e in this case, the div with "4")
<div class='elem'>1</div>
<div class='elem'>2</div>
<div class='elem'>3</div>
<div class='elem'>4</div>
<div class='elem'>5</div>
<div class='elem'>6</div>
I tried this but it selected last three divs.
$('div:gt(-3)').css('background':'red');
Kindly know that, i may not know the total divs(it's dynamic), but i only need to select the third div from bottom.