Last active
November 12, 2018 12:09
-
-
Save luisfelipe-dev/d240e3891b162c4f074a977912cd85c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| $(document).ready(function() { | |
| var url = window.location; | |
| var element = $('ul.sidebar-menu a').filter(function() { | |
| return this.href == url || url.href.indexOf(this.href) == 0; }).parent().addClass('active'); | |
| if (element.is('li')) { | |
| element.addClass('active').parent().parent('li').addClass('active') | |
| } | |
| }); | |
| </script> | |
| ---- | |
| Melhor Opção: | |
| $(function() { | |
| // this will get the full URL at the address bar | |
| var url = window.location.href; | |
| // passes on every "a" tag | |
| $(".menu .content-menu ul a").each(function() { | |
| // checks if its the same on the address bar | |
| if (url == this.href) { | |
| $(this) | |
| .closest("li") | |
| .addClass("active"); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment