Reputation: 5170
I have some groups of content which consists of two divs, both divs contain text, and I want the second div of each set to match the height of the first.
HTML (Cannot be changed unfortunately)
<!-- group one -->
<div class="item">
.... content here
</div>
<div class="item_open">
.... content here too
</div>
<!-- group two -->
<div class="item">
.... completely different content here
</div>
<div class="item_open">
.... some more content here too
</div>
Upvotes: 2
Views: 76
Reputation: 4278
Here is a fiddle using jQuery to achieve this.
$(".item_open").each(function(){
$(this).height($(this).prev().height());
});
Upvotes: 1
Reputation: 826
I'm pretty sure that what you are looking for could be found here: http://www.ejeliot.com/blog/61
(Using CSS and not JQuery)
Upvotes: 1
Reputation: 276
If you cannot change HTML, you can try in this way..
var $item = $(document).find('.item'); // find first tag item
var $itemNext = $item.next(); // return item_open
$($item, $itemNext).css({
height: '100px'
});
Upvotes: 0
Reputation: 57095
$('.item_open').height(function(){
return $(this).prev().height();
});
Upvotes: 2