小编Pau*_*oag的帖子

使用jquery或JS如何将字符串转换为链接?

所以我有一段看起来像这样的HTML ......

<p>This is some copy. In this copy is the word hello</p>
Run Code Online (Sandbox Code Playgroud)

我想使用jquery将单词hello转换为链接.

<p>This is some copy. In this copy is the word <a href="">hello</a></p>
Run Code Online (Sandbox Code Playgroud)

这本身并不太难.我的问题是,如果这个词已经是一个链接,如下面的例子...

<p>In this copy is the <a href="">word hello</a></p>
Run Code Online (Sandbox Code Playgroud)

我不希望最终在链接中找到链接...

<p>In this copy is the <a href="">word <a href="">hello</a></a></p>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激.

jquery dynamic-links

7
推荐指数
1
解决办法
2619
查看次数

标签 统计

dynamic-links ×1

jquery ×1