我已经清理了昨天的这个问题,希望问题能清楚。下面是一个简单的 JS,它找到最高的 li,然后使所有 li 都达到那个高度。当 ul 被放置在 jQuery 选项卡中并且当页面加载到第一个选项卡下时所有选项卡信息显示时会出现问题。单击选项卡(任何选项卡)后,所有内容都会自行解析并按应有的方式显示。为什么会这样?我该如何解决这个问题?
jsfiddle 应该清楚问题是什么。
$(document).ready(function() {
var maxHeight = 0;
$('ul#list li').each(function() {
maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight;
}).height(maxHeight);
$('.tabs .tab-links a').on('click', function(e) {
var currentAttrValue = $(this).attr('href');
// Show/Hide Tabs
$('.tabs ' + currentAttrValue).slideDown(400).siblings().slideUp(400);
// Change/remove current tab to active
$(this).parent('li').addClass('active').siblings().removeClass('active');
e.preventDefault();
});
});
最佳答案
你只需要在列表高度设置行后面加上$('.tab').hide();$('.tab.active').show();
,然后离开
.tab.active {display:block;left: 0px;}
参见 jsfiddle
关于jquery - jQuery 选项卡中的相同高度 li,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29496679/