how to select all divs inside another div and find the largest 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 divwhich has the largestid attribute
I use the following code to capture id attribute:
$('.posts .post').data('id');
But this returns the last , not the largest .
source
share