jQuery('.webform-component-checkboxes').each(function(){
var height = heightAdjustment(jQuery(this));
console.log(height);
});
function heightAdjustment(variable){
var temp = 0;
var elements = {};
var max;
jQuery(variable).find('.form-checkboxes .form-type-checkbox label.option').each(function() {
max = jQuery(this).parent().css('height');
temp = temp > max ? temp : max ;
elements = this;
});
elements.parent('div').siblings().css('height',temp);
}
我正在使用此代碼,但'loops'的值在循環外部變爲空。但它裏面的工作。
幫幫我!
你剛纔說的,元素只在功能範圍內都有效。 –
您不需要在jQuery標記中重新包裝'variable',因爲您已經將它傳遞給了jQuery對象。另外,'elements'是一個常規對象,不是jQuery元素的集合,所以你的最後一行將會失敗。 – Santi
'元素'應該包含什麼?什麼不起作用? – empiric