Hi,
Can anyone explain this query?
$(function() {
var pgurl = window.location.href.substr(window.location.href.lastIndexOf("/") +1);
$(".menu li a").each(function() {
if ($(this).attr("href") == pgurl || $(this).attr("href") == '')
$(this).addClass("active");
});
});
and why we add '1' in 3rd line (highlight with red color)?
Thanks in advance.

Anubhav ChaudharyPosted Aug 19, 2015, 8:04 AM
Rajeesh MenothPosted Aug 19, 2015, 8:01 AM
lastIndexOf() finds the last occurrence of your string in the string you're searching.So the first lastIndexOf() finds the last "/" in the href attribute of the link.+1 is needed, so that the url still contains the last "/".
Arjunan SelvamPosted Aug 19, 2015, 7:59 AM
Karthikeyan KPosted Aug 19, 2015, 7:53 AM