JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<button id="but" style="">body scan</button>
<div id="alpha" style="width:10px;background-color:#999;height:1999px;">asdfas<button>asdf</button>
</div>
<div id="beta" style="width:10px;background-color:#F00;height:1500px;position:absolute;bottom:-2000px">
</div>
JavaScript
var maxhabs = 0;
var maxhrel = document.body.offsetHeight; //get the offsetheight
var atotoffset=0;
var id="";
$('#but').click(function(){
$.each($('body *:not(script)'),function(){//get all body elements
if ($(this).css('position') == 'absolute'){//is absolute?
if(typeof($(this).offset().top)!='undefined'){//defined?
if(atotoffset < $(this).offset().top+$(this).context.offsetHeight){
atotoffset=$(this).offset().top+$(this).context.offsetHeight;
idabs = $(this).context['id'];
}//works for -/+ margin top/bottom & top/bottom crosssbrowser
}
}
});
maxhabs = atotoffset;//absolute element offset position from the top
if(maxhrel>maxhabs){
alert('higher:'+maxhrel);
}else{
alert('higher:'+maxhabs+' for the element:'+idabs);
}
});