javascript - Jquery to check the height of all children -


this question has answer here:

<a href="#" class="button">button</a> <div class="parent">      <div class="child">content 01</div>      <div class="child">content 02</div>      <div class="child">content 03</div>      <div class="child">content 04</div>      <div class="child">content 05</div> </div> 

here's html, have written rollover a.button , div.parent visible, , on rollout, div.parent's visibility set hidden.

i write script that, on a.button hover, jquery checks each height of div.child in div.parent, figures out tallest, , sets div.parent's height.

i know there each loop, don't know how , compare values.

thank in advance.

try out:

$('a.button').on('mouseenter', function() {     var maxheight = 0;     $('div.child').each(function() {         if ($(this).height() > maxheight) maxheight = $(this).height();     });     $('div.parent').height(maxheight); }); 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -