掉落列表问题
Drop List problems
我写了一个包含2个子类别的下拉列表。当我打开第一个目录时,它会无缝地打开,但每当我打开靠近底部的第二个目录时,分类就不会完全展开。我在JsFiddle上有一段代码,如果有人能看一下,我将不胜感激。我认为这是我的jQuery的问题,但也可能是我的HTML的问题,所以这就是为什么我在下拉列表中包含了所有相关的内容。具体来说,我的问题在于2013年的类别。
这是我的Jquery:$(document).ready(function(){
$('.tab_container').click(function(){
if( $(this).parent().is('.open') ){
$(this).closest('.tabSlot').find('.tab_container_expanded').animate({'height' : '0'},500);
$(this).closest('.tabSlot').removeClass('open');
}else{
var newHeight =$(this).closest('.tabSlot').find('.tabs_expanded').height() + 'px';
$(this).closest('.tabSlot').find('.tab_container_expanded').animate({'height' : newHeight},500);
$(this).closest('.tabSlot').addClass('open');
}
});
});
$(document).ready(function(){
$('.tab_containerb').click(function(){
if( $(this).parent().is('.open') ){
$(this).closest('.tabSlotb').find('.tab_container_expandedb').animate({'height' : '0'},500);
$(this).closest('.tabSlotb').removeClass('open');
}else{
var newHeight =$(this).closest('.tabSlotb').find('.tabs_expandedb').height() + 'px';
$(this).closest('.tabSlotb').find('.tab_container_expandedb').animate({'height' : newHeight},500);
$(this).closest('.tabSlotb').addClass('open');
}
});
});
我觉得我在第二个函数中需要另一个我无法理解的语句,但我就是这么想的。
问题是,你正在使用高度来控制菜单和高度不正确计算时,你有子元素的高度等于0
我把你的代码改为使用slideUp()
和slideDown()
,使用display: none;
代替height: 0;
,它工作了。
主要问题隐藏在你的css,你应该使用display:none而不是溢出hidden和height为0因为查询中的固定高度不足以显示所有子菜单项。所以使用$.show()代替。
相关文章:
- jQuery,引导程序下拉列表问题
- JQuery刷新列表效果-淡入淡出问题
- jQuery拖动到相对位置的可排序列表中时出现可拖动辅助对象位置问题
- jQuery切换列表菜单问题
- 当前用户顶部列表的曲目快照出现间歇性问题
- 为了在列表中搜索,角度过滤器有问题
- 我正试图获得一个带有复选框的多选下拉列表,在填充项目和获得所有选中的工作时遇到了一些问题
- 访问knockout.js选择列表中的值时出现问题
- 面临从模型中为下拉列表设置值的问题
- JQuery Mobile自定义下拉列表问题
- SAPUI5绑定问题:json文件中维护的列表项链接不起作用
- MVC中选择下拉列表的设置值出现问题
- 将JSON REST请求加载到Kendo ui列表视图中的问题
- 我无法将变量从动态列表传递到php页面进行处理.这是我不理解的逻辑问题吗
- ASP.NET MVC级联下拉列表列出Javascript问题
- 列表/数组的迭代问题
- jQuery Date 下拉列表的问题
- 可以在网站上嵌入Github问题列表(带有特定标签)
- 浏览器兼容性问题列表
- 无法获取具有相同参数的多个实例的问题列表