I have this tool that uses both hard and relative links for local pages. (I didn't build it) I now need to classify external links. Tried with this but it gets stuck at the 'else if' level. What am I doing wrong? Without the 'else if' it mistakenly marks some local links as external, but with it, nothing happens.
jQuery(document).ready(function() {
var comp = new RegExp(location.host);
jQuery('a').each(function(){
if(comp.test(jQuery(this).attr('href'))) {
jQuery(this).addClass('local');
}
else if(jQuery(this)('a[href$="ABC"]')) {
jQuery(this).addClass('local2');
}
else {
jQuery(this).addClass('external');
}
});