cusejuice cusejuice - 4 months ago 25
jQuery Question

Remove anchor tags using jQuery

My html:

<div class="example">
<a id="link" href="http://www.google.com">Example</a>
</div>


jQuery

$('a#link').remove();


What I would like to do, is make the html look like this after the
<a>
tag is removed:

<div class="example">
Example
</div>


How do I remove just the

<a> </a>


part?

Answer

Alternate solution:

$("a#link").replaceWith($("a#link").text());