-6

I want to find a string like link and replace it with a <a href="#link">link</a>.

Update: After the body is loaded.

Huangism
  • 16,278
  • 7
  • 48
  • 74
The Riot
  • 41
  • 3
  • 10

2 Answers2

1

Your question was unclear for me. But the following should work

$( document ).ready(function() {
 document.body.innerHTML = document.body.innerHTML.replace(/target string/g, "replacement string");
});
Dennis Anderson
  • 1,348
  • 2
  • 14
  • 33
1

jQuery answer:

<p>link</p>

$('body').html($('body').html().replace('link', '<a href="#link">link</a>'));

http://jsfiddle.net/bevanr01/2wttp42j/9/

Russell Bevan
  • 334
  • 1
  • 13