Created
February 5, 2017 19:53
-
-
Save alexdev27/1018d593172aded943f2b5d867881349 to your computer and use it in GitHub Desktop.
установка активного элемента в зависимости от url
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
$(function() { | |
$('.aside-nav__item, .mob-menu__list li').each(function(indx) {//поиск нужных элементов | |
var e = $(this); | |
e.removeClass('aside-nav__item--active active-item'); | |
var href = location.pathname.split("/")[1] ; | |
if (href === '') { | |
e.find('a[href^="index.html"]') .parent(e) | |
.addClass('aside-nav__item--active'); | |
} | |
else{ | |
e.find('a[href^="' + href + '"]') | |
.parent(e).addClass('aside-nav__item--active'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment