用jQuery替换文本链接 [英] Replace a link with it's text with jQuery

查看:79
本文介绍了用jQuery替换文本链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<a href="#">TEST</a>

我要删除锚点并保留文本,即测试

I want to remove the anchors and keep the Text i.e TEST

推荐答案

您还可以使用新的 $.unwrap 方法( jQuery 1.4 + )应用于 contents 锚点:

You could also use the new $.unwrap method (jQuery 1.4+) applied to the contents of the anchor:

​$('a').contents().unwrap();​​

此处查看示例.

这篇关于用jQuery替换文本链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆