[jQuery] How to add a CSS class to external links
// apply a class to all <a> which respect the filter selection.
$('a').filter(function() {
return this.hostname && this.hostname != location.hostname;
}).addClass('external');
About
Hi, I'm Christian Castelli, a 28 years old italian programmer located in Pisa (Italy). Here I post small snippets of code which can be useful in my work.Links
Codepuzzling main siteMy Life Style
while(passion) {
try {
myLife.run();
}catch(LifeExceptions) {
stronger++;
continue;
}
}
Following
// apply a class to all <a> which respect the filter selection.
$('a').filter(function() {
return this.hostname && this.hostname != location.hostname;
}).addClass('external');