javascript - find the height of a div and change the current div height to match -


i'm trying make div same height parent (if parent larger) or make parent same height current div (if current div larger)

here's i've got far

$(this).parents().find('.address').slidetoggle(function() {     $(this).parent().height($(this).parent().find('.address').height()) }) 

it makes parent height of current div (but in current case parent larger current div

any ideas?

thanks

jamie

check solution here

sample html:

<div id="parent" style="height:500px;border:1px solid #000000">     <div id="child" style="height:300px;border:1px solid #000000">child</div> </div> 

javascript:

 jquery(document).ready(function() {                  var $parentdiv = $('#parent');                  var $childdiv = $('#child');                         if($childdiv.height() > $parentdiv.height())                       $childdiv.css('height', $parentdiv.height());                                 else                      $parentdiv.css('height', $childdiv.height());           }); 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -