L
L
lavezzi12015-09-26 09:12:09
css
lavezzi1, 2015-09-26 09:12:09

Highlight active menu item by url in jquery?

Hello. Tell me a script for highlighting a point by its url, so that you don’t write code for highlighting on each page.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
jlekapb, 2015-09-26
@lavezzi1

Hey!
There is support for nested menu items:
codepen.io/lkp/pen/vOPgzY

V
Vitaly Inchin ☢, 2015-09-26
@In4in

In Google, everything is jam-packed on a similar issue.

var l = location.href.split("#")[0]; //Отбросим хэш

[].some.call(document.querySelectorAll("#punkti > a"), function(a){
  //Добавим нужному пункту класс active
  if(a.href == l) return a.classList.add("active"), true; 
});

L
Leonid Smirnov, 2018-11-26
@SunyJun

Here is the answer to your question - https://www.pandoge.com/moduli_i_skripty/vydelyaem...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question