js 导航脚本 ,判断当前导航

发布时间:2020-06-27 18:44:10 作者:小仙女KOMons
来源:网络 阅读:626

<script>

    $(function () {

        //highlight current / active link   左侧导航判断当前活动导航

        $('ul.main-menu li a').each(function () {

            var wo = window.location.href.substring(window.location.href.lastIndexOf('/') + 1, window.location.href.lastIndexOf('.'));


            if ($(this).attr('href') == (wo + ".html")) {

                $(this).parent().addClass('active');

                $(this).parents().addClass('active');

                $(this).parents('li').find("i:first").toggleClass("glyphicon-minus");

                $(this).parents('ul').slideDown();


            }else

                if (("dxs" == wo || "syd" == wo)&&($(this).attr('href')=="dbs.html")) {

                  

                    $(this).parent().addClass('active');

                    $(this).parents().addClass('active');

                    $(this).parents('li').find("i:first").toggleClass("glyphicon-minus");

                    $(this).parents('ul').slideDown();


            }

        });

   /*** begin 主页左侧菜单 */ 

    $(".main-menu a").click(function () {

        //将当前li设置为活动状态

        $(this).find("i:first").toggleClass("glyphicon-minus");


    });

    $(".main-menu a").click(function () {

        //更换其他导航的加减号图标

        $(this).parent('li').siblings(".active").find("i:first").toggleClass("glyphicon-minus");

        //alert($(this).index());

       

        //去掉其他导航的点击样式并折叠

        $(this).parent('li').siblings(".active").removeClass("active").children("ul").slideUp('fast');

        $(this).next('ul').slideToggle('fast');

        $(this).parent('li').addClass('active');

    });


    /************** end 主页左侧菜单 */

})

</script>


推荐阅读:
  1. 基于HTML5&Js的在线导航系统架构
  2. JS 百度地图导航

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

jquery menu 导航脚本

上一篇:php趣味编程 - php 赛场得分统计

下一篇:string.xml字符串的格式化和样式(Formatting and Styling)

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》