So I have a piece of HTML that looks something like this...
<p>This is some copy. In this copy is the word hello</p>
I want to turn the word hello into a link using jquery.
<p>This is some copy. In this copy is the word <a href="">hello</a></p>
That in itself is not too hard. My problem is that if the word is already apart of a link like the example below...
<p>In this copy is the <a href="">word hello</a></p>
I don't want that to end up with a link within a link...
<p>In this copy is the <a href="">word <a href="">hello</a></a></p>
Any help would be much appreciated.
First keep the words while getting rid of the current anchor tag, if there is one:
Then do a replace on the string that you need to work with