I'm wondering if its possible to addClass to a link, that has the same href as the document.href?
I tried, but without any luck.
if ($("a").attr("href") == document.location.href) {
$(this).addClass("active");
}
Isn't this possible??
I'm wondering if its possible to addClass to a link, that has the same href as the document.href?
I tried, but without any luck.
if ($("a").attr("href") == document.location.href) {
$(this).addClass("active");
}
Isn't this possible??
$("a").filter(function() {
return this.href === document.location.href;
}).addClass("active");
Should work.