You have a list of elements with an attribute or data value and you need the max value or min?
something list this:
<div class="row" detid="1" data-rowid="10">
<span class="ordernum"></span>
</div>
<div class="row" detid="2" data-rowid="30">
<span class="ordernum"></span>
</div>
<div class="row" detid="3" data-rowid="20">
<span class="ordernum"></span>
</div>
<div class="row" detid="4" data-rowid="0">
<span class="ordernum"></span>
</div>
now the only thing you need is
let max = 0;
let rows = $(".row").map(function (ind, row) {
return $(row).data("rowid");
}).sort(function(a, b) {
return a-b;
});
and you have your values
Max = rows[rows.length-1];
min = rows[0];
here is the link to play around
try it at jsfiddle