I have the following divs:
test test
var min = Number.MAX_VALUE, max = Number.MIN_VALUE; $(".maindiv").each(function () { var id = parseInt(this.id, 10); if (id > max) { max = id; } if (id < min) { min = id; } });