-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
  • 15,899
  • 5
  • 47
  • 67
The Riot
  • 41
  • 2
  • 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,199
  • 2
  • 12
  • 30
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