1

I saw this add nofollow tag but how do i exclude more domains. The script only allows 1 url only. Thanks

jQuery(document).ready(function () {
    jQuery('a[href*="http://"]:not([href*="http://domain.com/"])').attr('rel', 'nofollow');
    jQuery('a[href*="https://"]:not([href*="http://domain.com/"])').attr("target", "_blank");
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Origami
  • 115
  • 5
  • 14

1 Answers1

1

You can separate attribute selectors in the :not selector with a comma:

jQuery('a[href*="http://"]:not([href*="http://domain.com/"],[href*="http://example.com/"])')
    .attr({ rel: 'nofollow', target: '_blank' });
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339