How To Create Menu Active link Using java script in website



How To Create Menu Active link Using java script in website 



<script>
        function onCancel() {
            window.location.href = "/Home/Index";
        }

        $(function () {
            setNavigation();
        });

        function setNavigation() {
            var path = window.location.pathname;
            path = path.replace(/\/$/, "");
            path = decodeURIComponent(path);

            $(".sidebar-menu a").each(function () {
                var href = $(this).attr('href');
           
                if (path.substring(0, href.length) === href) {
                    $(this).parents('li').parents('li').addClass('active');
                    var path1 = path.split('/');
                    var heref1 = href.split('/');
                    if (path1[2] === heref1[2]) {
                        $(this).parents('li').addClass('active');
                    }
                }
               
            });
        }
    </script>

No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

Sql dynamic query With Join And search using like query with multiple column

Sql dynamic query With Join And search using like query with multiple column declare @keyword varchar(100) DECLARE @sqlCommand va...

Popular Posts