You can use the sort function to do it.
function arrayify(obj){
return [].slice.call(null,obj);
}
var all = arrayify(document.querySelectorAll('div[id]'));
var max = all.sort().pop();
var min = all.sort().reverse().pop();
This is way easier that using jQuery