javascript去掉a标签的方法:首先找到相应的js代码部分;然后通过“str.replace(/(<\>)|(<\>)/g, '');”方法去掉a标签即可。

本文操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。
javascript怎么去掉a标签?
具体问题:
js 去a标签留内容
立即学习“Java免费学习笔记(深入)”;
怎么用正则去除a标签,只留下内容 http://git.oschina.net
将a标签部分替换为空的方式,不是直接取a标签的内容,因为有很多这样的代码,而且还有其它代码要留在原地
<a href="http://git.oschina.net/" style="box-sizing: border-box; color: rgb(51, 51, 51); text-decoration: none; transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1); -webkit-transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1); max-width: 100%; transparent;"><span data-wiz-span="data-wiz-span" style="box-sizing: border-box; max-width: 100%; font-size: 14pt;">http://git.oschina.net</span></a>
实现方法:
(<\/?a.*?>)|(<\/?span.*?>)
也就是:
str.replace(/(<\/?a.*?>)|(<\/?span.*?>)/g, '');
运行结果

【推荐学习:javascript高级教程】
以上就是javascript怎么去掉a标签的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号