If I have a block of text inside a div like:
<div id='t1'>
This is a great testing string. Tomorrow grass is green.
</div>
and I want to replace all instance of the letter “g” with a link to google, like
<a href='www.google.com'>g</a>
Is it possible to do this with just Javascript/jquery?
If you want to perform a simple string replacement, the following will do:
If you need more dynamics, e.g. substituting a word with a link, depending on the value, use:
Example: Replace g or G with different URLs: