我有一个工作的jQuery手风琴菜单。有一件事情仍然不会成功。
当我打开菜单并单击链接时,菜单再次关闭。我希望菜单保持打开状态,并且仅在打开另一个菜单时关闭。
对不起我的英语不好。
jQuery代码
$(document).ready(function(){
$('.item').click(function(){
if($(this).css('max-height') == '37px') {
$(this).css('max-height','240px')
}else {
$(this).css('max-height','37px')
}
});
});
我希望有人能帮助我。
这是用于html和css的jsfiddle:http://jsfiddle.net/aAn8n/
最佳答案
试试这个
$('.kop').click(function(){
var $parent = $(this).parent(".item");
if($parent.css('max-height') == '24px') {
$(".item").css('max-height','24px');
$parent.css('max-height','240px');
}else {
$parent.css('max-height','24px');
}
});
工作DEMO