how do I select all the divs inside another div and find the greatest id attribute?
Consider the following code:
<div class="posts">
<div class="post" data-id="5"></div>
<div class="post" data-id="3"></div>
<div class="post" data-id="1"></div>
<div class="post" data-id="4"></div>
</div>
What I want to do is, find the div
that's having the greatest id attribute
I use the following code to grab the id attribute
:
$('.posts .post').data('id');
But that returns the latest one, not the greatest.