我写了一个小脚本来比较2格的高度,并将最大格的高度设置为另一个格。
我的问题是:如何改进此脚本?。因为我目前正在重复获取2 div的皮革的部分
$( document ).ready(function() {
showHeight($( "#tab-content2" ).height());
showHeight($( "#tab-content1" ).height());
});
var bheight = 0;
function showHeight(height) {
if( height > bheight){
bheight = height;
$("aside").height(bheight + 60);
}
}
通过选择所有以ID开头的ID来选择它们两者,tab-content
然后使用.each
$(document).ready(function() {
$("div[id^='tab-content']").each(function(){
showHeight($(this).height());
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句