0

Has anyone tried writing a piece of code that would 'scan' a content of a certain div, and modify every link inside it so that it adds rel="nofollow" to each link?

I'm asking, because i can't add nofollow tag to certain links on my page, but since they are all in the same div, i would like to see if the above idea is possible to execute?

Also, i forgot to mention: Is this method safe SEO wise - as Thad Blankenship mentioned below - will crawlers crawl those links before a proper bit of jquery code that adds no follow to links is executed?

idjuradj
  • 1,355
  • 6
  • 19
  • 31

1 Answers1

0

With jquery it's quite easy.

$('#div-id a').attr('rel', 'nofollow');

However, I don't know how most search engines work, but I doubt this would affect them. They probably parse the page looking for nofollows BEFORE javascript is run. Not 100% on this though.

Basically, although you can do this with javascript, don't count on search engines abiding by rel attributes added after the DOM loads.

Thad Blankenship
  • 2,242
  • 3
  • 16
  • 16