我对我正在编写的一个小函数感到疯狂。jquery不适用css属性
该功能需要将容器的高度设置为与其中存在的最高UL(总共3个UL和绝对位置)相等,如果第二个或第三个UL低于第一个,则将高度这些UL等于第一个。
这是函数:
function fixNavHeight() {
var cont = white,
arr = [];
lis = $('nav li');
lis.each(function() {
var li = $(this);
li.mouseenter(function() {
var childrenHeight = $(this).find(secondaryNavigation).height();
cont.css('height', childrenHeight);
setHeight(childrenHeight);
});
});
function setHeight(base) {
arr = [];
cont.find('ul').each(function() {
if($(this).is(':visible')) {
var h = $(this).height();
console.log(h);
if(h <= base) {
$(this).css('height', base);
}
arr.push(h);
var biggest = Math.max.apply(null, arr);
cont.css('height', biggest);
}
});
}
}
一切工作正常,但如果UL低于base
它不设置CSS高度,我不明白为什么。
你能帮我找到问题吗?
我在做什么错在这里?
你可以在'console.log(h)'后面试一下'console.log(base)'吗? – Korcholis
我现在又试了一次,它返回“null”... –
'''var cont = white,''white'来自哪里? – Nelson