根据url自动展开JQuery嵌套菜单
Auto expand JQuery nested menu depending on url
我正在使用它在我的站点中获得可扩展菜单
$(document).ready(function () {
$('li.category').addClass('plusimageapply');
$('li.category').children().addClass('selectedimage');
$('li.category').children(":not(a)").hide();
$('li.category').each(
function (column) {
$(this).click(function (event) {
if (this == event.target) {
if ($(this).is('.plusimageapply')) {
$(this).children().show(200);
$(this).removeClass('plusimageapply');
$(this).addClass('minusimageapply');
}
else {
$(this).children(":not(a)").hide(200);
$(this).removeClass('minusimageapply');
$(this).addClass('plusimageapply');
}
}
});
}
);
});
如何使其自动扩展到当前菜单?我的链接采用格式
/Article/Category1/Category3
如果我在这个URL,我想扩展类别3,它在类别1下。菜单项的格式为
<li class="category">
<a href"/Article/Category1/Category3/">Category3</a>
<ul> ... [more sub-categories] ... </ul>
</li>
使用window.location.pathname
将其与菜单的链接相匹配。
看看这个问题,了解如何使用jQuery:做到这一点
使用jQuery将当前URL与UL中的herf匹配,如果匹配,则添加类
相关文章:
- 根据url自动展开JQuery嵌套菜单
- Javascript/JQuery嵌套if语句工作不正常
- jquery嵌套函数中的全局变量
- jQuery嵌套的电话号码验证
- jQuery嵌套循环nextUntil选择器
- 如何使 jquery 嵌套选项卡链接工作
- Jquery 嵌套的添加/删除
- 如何调用 jQuery 嵌套函数
- jQuery 嵌套函数
- jQuery嵌套的XML元素
- IE中的jQuery嵌套选项卡设计问题
- Jquery 嵌套选项卡
- Jquery嵌套表创建干净的方法
- jQuery嵌套:eq选择器
- jQuery嵌套插件选择器问题
- jquery嵌套类悬停
- Jquery嵌套不更新
- jQuery嵌套.each循环超过JSON成功
- jQuery嵌套$(this)在complete函数内失败
- Javascript颜色小偷在jquery嵌套循环