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>

1 comment:

  1. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks hospedaje web compartido

    ReplyDelete

Thank You For Your Great Contribution

Featured Post

How to remove multiple item from FormArray

 How to remove multiple item from FormArray Call Method at any component :- this.removeItems(formArray, formcontrolCountryID, 2);  Meth...

Popular Posts