jquery - How to add specific height of an element to another -
i've got html code that:
<section> <div> </div> </section> <section> <div> </div> <section>
i don't have specific height of of element. , wanna section height , give inner div height. how can jquery?
i've tryed this:
$(document).ready(function() { var contentheight = $('.content').parent().height(); $(".content").height(contentheight); }); $(window).resize(function() { var contentheight = $('.content').parent().height(); $(".content").height(contentheight); });
but takes height of first section , apply of inner divs.
in $(window).resize
section, replace code this:
$(window).resize(function() { $(".content").each(function(){ $(this).css('height', $(this).parent().height()+'px'); }); });
the reason first ".content"
affected, $('.content')
returns array of matching elements, .height()
part returns first element of array. solution iterate through entire set of ".content"
elements using .each(function(){...})
Comments
Post a Comment