Hi all,
I am trying to implement a function whereby the user selects some text and on click of a button a set of span tags are wrapped around that selected text. If the text contains within it another set of tags(for example a href) it will surround the text with span tags aswell.
<p> I went to the market yesterday to buy some <a href="url">fruit and vegetables</a> and then walked home instead catching the car </p> <p> The next day I did the same thing </p>
So if the user selects from "I went to the" to "The next day" it would look something like this:
<p><span color = 'blue'> I went to the market yesterday to buy some </span> <a href="url"><span color = 'blue'>fruit and vegetables</span></a><span color = 'blue'> and then walked home instead catching the car<span> </p> <p><span color = 'blue'> The next day </span color=blue> I did the same thing </p>
Any idea how I can do this?
Thanks
Kind regards
Chris
I am trying to implement a function whereby the user selects some text and on click of a button a set of span tags are wrapped around that selected text. If the text contains within it another set of tags(for example a href) it will surround the text with span tags aswell.
<p> I went to the market yesterday to buy some <a href="url">fruit and vegetables</a> and then walked home instead catching the car </p> <p> The next day I did the same thing </p>
So if the user selects from "I went to the" to "The next day" it would look something like this:
<p><span color = 'blue'> I went to the market yesterday to buy some </span> <a href="url"><span color = 'blue'>fruit and vegetables</span></a><span color = 'blue'> and then walked home instead catching the car<span> </p> <p><span color = 'blue'> The next day </span color=blue> I did the same thing </p>
Any idea how I can do this?
Thanks
Kind regards
Chris
Comment