hasClass not working for some reason...
Hi,
I've been pulling my hair out trying to figure out what is wrong with my code here:
- // Add attributes to external links
- if($('a').hasClass('notexternal')) {
- // do nothing
- } else {
- $("a[href*='http://']:not([href*='"+location.hostname+"']), a[href*='https://']:not([href*='"+location.hostname+"'])").attr('title','External link').attr('rel', 'external');
- }
Basically, I'm trying to make any links
without the class 'notexternal' and that has an external domain have:
1. A title attribute of 'External link'
2. A rel attribute of external
However, everything within the 'else' part of the statement above doesn't work. I've tried replacing it with other code to test, but I can't get it to respond... can anyone see what I'm doing wrong?
Thanks,
Osu