【发布时间】:2011-07-26 14:34:56
【问题描述】:
我正在开发clients site,它有一个侧边栏菜单,其中包含产品类别和产品作为产品类别的子菜单。问题是,我让它切换,如果你点击产品类别,它会打开子菜单,如果再次点击,它会关闭。现在,如果我单击子菜单上的产品,我会进入产品页面,但我还需要它以打开状态显示子菜单。
到目前为止,代码是...
$("#sidebar ul li a").click(function(e){
if( $(this).parent().children('ul').length > 0 ){
e.preventDefault(); //prevent the link from being followed
$(this).parent().find('ul').toggle('100');
}
});
现在,我希望它有类似 ...
if( $("#sidebar .current_page_item") (<< has two ULS, meaning it's a submenu >>)
$(this). (<< some code to make the submenu display:block >>)
}
然而,我不知道如何做到这一点,任何帮助将不胜感激。
【问题讨论】:
-
甚至不知道那件事,做了一些研究并纠正了自己。感谢您的提醒。