How can I convert the text in a link to an html element?
I'm targetting the text with
which returns the value but I can't add the element to it.$('a').text();
I've tried this:
var someText = $('a').text();
var theElement = $('< p >' + someText + '< /p >');
someText.replaceWith(theElement);
I know this supposedly would add a text element inside the link which is not the best practice but not even this works.
what I really need is to remove the whole text and rewrite it immediately after de link as a text element.
any help is appreciated. thank you
markup:
<li>
<a href="/"> <img src="image.png"> text to be converted to element </a>
</li>
what I want:
<li>
<a href="/"> <img src="image.png"></a>
<p> text to be converted to element </p>
</li>
` element, containing the same text?
– David Thomas Apr 02 '15 at 18:02