Reputation: 532
As the title says, I'm getting the location hash and storing it in a var. I'm then searching for a link with a name attribute which matches the hash and adding a class to it.
The code I'm currently using is:
var hash = window.location.hash.substring(1);
$('a[name*='+hash+']').addClass("boo");
Not having any luck though? Any suggestions would be greatly appreciated.
Upvotes: 0
Views: 44
Reputation: 7207
your code is fine, just drop the star (*) and add quotations to hash:
var hash = window.location.hash.substring(1);
$('a[name="'+hash+'"]').addClass("boo");
Upvotes: 1