我有一系列领域,如:
<div class="field-label-inline">
<div class="field-label">something1</div>
<div class="field-items">
<div class="field-item">sometext1</div>
</div>
</div>
<div class="field-label-inline">
<div class="field-label">something2</div>
<div class="field-items">
<div class="field-item">sometext2</div>
</div>
我想让 .field-label div 的所有实例与相邻的 .field-items div 具有相同的高度(此 div 的高度根据其内容而有所不同)。可悲的是,我的 jQuery 几乎不存在;这是我最好但失败的尝试:
$(document).ready(function(){
$('.field-label-inline > .field-label', this).each(function(){
var itemsHeight = 0;
itemsHeight = $(this + .field-items).height();
$(this).height(itemsHeight);
});
});