Reputation: 1403
<a href="#">TEST</a>
I want to remove the anchors and keep the Text i.e TEST
Upvotes: 18
Views: 6256
Reputation: 268324
If you want to remove the link and leave the text:
$("a").replaceWith(function(){ return $(this).text() });
Online Demo: http://jsbin.com/aguki/edit
If you're using jQuery 1.4+, CMS provided an even shorter answer.
Upvotes: 6
Reputation: 827198
You could also use the new $.unwrap
method (jQuery 1.4+) applied to the contents
of the anchor:
$('a').contents().unwrap();
Check an example here.
Upvotes: 32