В ff можно вот так
:
<div class="N" id="3"> </div>
<div class="N" id="1"> </div>
<div class="N" id="12"> </div>
<div class="N" id="4"> </div>
<div class="N" id="2"> </div>
<script>
alert(
Array.reduce(
document.querySelectorAll(".N"),
(previous, {id:current}) => Math.max(current, previous),
-Infinity
)
);
</script>