Home >Backend Development >PHP Tutorial >javascript - 有一段带有URL的文本,想在前端可以实现超链接点击,要怎么弄?前端有好办法吗?

javascript - 有一段带有URL的文本,想在前端可以实现超链接点击,要怎么弄?前端有好办法吗?

WBOY
WBOYOriginal
2016-06-06 20:14:011236browse

文本是:

<code>婕妤阁自然印象五色眼影点亮明眸,持久闪耀 券后9.9元包邮秒杀,纯福利!! 券后9.9元包邮秒杀,纯福利!! 30元电脑券:http://dwz.cn/2RbiD4 30元手机券:http://dwz.cn/2Rbidk 券后9.9元秒杀链接:http://s.click.taobao.com/t?e=m%3D2%26s%3DlJP64KBy4n0cQipKwQzePOeEDrYVVa64qu1K02Mshg63bLqV5UHdqc1Z8EWGpjb8IfNVgZHErC4qC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPIkDB4%2BhZGeu4jvn1Cnq4FRWJGtyXF33fb0bE%2FrR0l%2Fx0BLb%2BpKxka6%2BObly8YvHIpLMLhz%2Bon5e%2BUUq5xoumkE%3D 款配色,总有一款适合爱美的你

</code>

想让其中超链接可以直接点击要怎么弄?非要正则拼接吗?正则不太会弄.有没有简单的办法?

回复内容:

文本是:

<code>婕妤阁自然印象五色眼影点亮明眸,持久闪耀 券后9.9元包邮秒杀,纯福利!! 券后9.9元包邮秒杀,纯福利!! 30元电脑券:http://dwz.cn/2RbiD4 30元手机券:http://dwz.cn/2Rbidk 券后9.9元秒杀链接:http://s.click.taobao.com/t?e=m%3D2%26s%3DlJP64KBy4n0cQipKwQzePOeEDrYVVa64qu1K02Mshg63bLqV5UHdqc1Z8EWGpjb8IfNVgZHErC4qC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPIkDB4%2BhZGeu4jvn1Cnq4FRWJGtyXF33fb0bE%2FrR0l%2Fx0BLb%2BpKxka6%2BObly8YvHIpLMLhz%2Bon5e%2BUUq5xoumkE%3D 款配色,总有一款适合爱美的你

</code>

想让其中超链接可以直接点击要怎么弄?非要正则拼接吗?正则不太会弄.有没有简单的办法?

我也只能想到用正则匹配然后包一层<a></a>
http://jsfiddle.net/mplungjan/Y5y5q/

这个可以用a标签实现吧,你显示的链接

学就可以了嘛。难道你想搞得像 Text Link 那样强大而复杂吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn