Jquery addclass to the current a tag, not to all a tags inside div?

I'd try to be more clear in your code about what you're trying to do. If you're trying to only apply a class to a certain link, then only select that link.

I'd try to be more clear in your code about what you're trying to do. If you're trying to only apply a class to a certain link, then only select that link: $('#products ahref="' + window.location. Href + '") .

AddClass('selectedThumb') ; If this was something you particularly needed to select often, it might be neat to extend jQuery: $. Extend($. Expr':', { currentPage: function(el) { return el.

Href && el. Href === window.location. Href; } }); // then... $('a:currentPage').

AddClass('selectedThumb').

Wow, thanks for the quick responses! I added some more details on my code, hope that helps a bit. @nick, I tried your example but for some reason not working still.

– taulant Dec 10 '10 at 18:07.

Maybe try to match the url (untested): var loc = window.location. Href; $("#products a"). Each(function() { if (loc.

Match(this. Href) { $(this). AddClass("selectedThumb"); } }).

Loc. Match(this. Href) isn't a good comparator."http://example.com/some/deep/link".

Match("http://example.com") == true – nickf Dec 10 '10 at 17:07 Yeah, I was assuming he was using relative paths =/ – fudgey Dec 11 '10 at 4:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions