jquery - Calculate div max-height using javascript -


i have div is, hypothetically sandwiched between many elements , on sidebar. need calculate how space there between div , element below it. , set max-height of div it's current height plus space below, never extends past (thus extending page). initial max-height, small value, should changed js. so, basically:

<thing></thing> <div id="mydiv"></div> <another></another> 

and need (jquery example):

var spacebelow = space between mydiv , <another>     var daheight = (currentheight + spacebelow);      $("#mydiv").attr("style", "max-height:" + daheight + "px"); 

is there anyway this?

i think want :-

    var divoffset=$(#divid).offset();     var divanotheroffset=$(#divanotherid).offset();     var spacebelow =divanotheroffset.top-divoffset.top;     var currentheight =$(#divid).height();     var daheight = (currentheight + spacebelow);      //set max-height:-      $("#mydiv").attr("max-height",daheight ); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -