Answer the question
In order to leave comments, you need to log in
JS how to correctly go through the elements by links and if the link matches the get add a class to it?
I do a check on the url get-parameter, and if the block contains this link, then I add a class to it
$('.navigation-list__item a').each(function() {
var link = jQuery(this).attr("href");
if (link === get) {
(this).parentNode.addClass("navigation-list__item_active");
}
});
(this).parentNode.addClass("navigation-list__item_active");
Answer the question
In order to leave comments, you need to log in
Need to be replaced
(this).parentNode.addClass("navigation-list__item_active");
$(this).parent().addClass("navigation-list__item_active");
$(this).closest(".navigation-list__item").addClass("navigation-list__item_active");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question