I want to disable all links within a div and replace it with the content that was there.
i.e.
<div><a href="/blah.html">My super link</a></div>
to
<div>My super link</div>
Thanks
I want to disable all links within a div and replace it with the content that was there.
i.e.
<div><a href="/blah.html">My super link</a></div>
to
<div>My super link</div>
Thanks
You can do it using .replacewith() and a function, like this:
$("div a").replaceWith(function() { return $(this).text(); });
Hmm - mine is similar to the other quicker-typists' answers, but I would have thought html() would have been what you wanted to use:
$('div a').each(function() {
$(this).replaceWith($(this).html());
});