jQuery:禁用div中的所有链接 - 替换为内部内容

Chr*_*ris 2 jquery

我想禁用div中的所有链接,并将其替换为那里的内容.

<div><a href="/blah.html">My super link</a></div>
Run Code Online (Sandbox Code Playgroud)

<div>My super link</div>
Run Code Online (Sandbox Code Playgroud)

谢谢

Nic*_*ver 5

你可以使用.replacewith()和一个函数来做,像这样:

?$("div a").replaceWith(????function() { return $(this).text();? });?
Run Code Online (Sandbox Code Playgroud)

你可以在这里看到一个快速演示