Your code is not ok.Here:
$("#mydiv a").each(function (index) {
if (lnk.indexOf($(this).html().trim().toLowerCase().replace(" ", "-")) != -1) {
$(this).parent().addClass('active');
}
});
$(this).html() will return
<span class="w-nav-title">Word from the Chairman</span>
But you need to check if the url from
window.location.href
exists in any hyperlink href value, right? In that case you can use
$(this).attr('href')
instead of
$(this).html()
for the comparison, because $(this).attr('href') will return the url used in the a tag.