The match
method[
^] takes a regular expression as its argument, and either returns an array containing the matches, or
null
.
Your
href
is not a regular expression, but since it doesn't contain any special characters, it will act like one. It doesn't contain any anchoring clauses, so your
match
call will return a match if the URL
contains the specified value.
Since all of the URLs you've shown contain the "All watches" URL, that one will always be marked as active.
To compare the full URL, use the equality operator:
$(function(){
$("#custom_html-2 a").filter(function(){ return location.href === this.href; }).addClass("tag-active");
});