Add class to external links Posted on November 9, 2022 in Code Snippets View news by category Accessibility (1) Advertising and Marketing (1) Animation (3) Backups (1) Checklists (1) Code Snippets (12) Functions (4) GSAP (2) Hosting (1) jQuery (7) Maintenance (2) PHP (4) Plugins (4) Security (1) SEO (3) Slider (1) Social Media (1) Top tips (2) Uncategorised (62) Updates (1) WordPress Plugins (2) jQuery: $("a, button").filter(function() { return this.hostname && this.hostname !== location.hostname; }).addClass('external');