在页面加载时将#hash 标签更改为链接 [英] Change #hash tag to link on page load

查看:18
本文介绍了在页面加载时将#hash 标签更改为链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改#标签+字符以使用javascript进行链接

这是#right 在路上

这就是<a href="http://twitter.com/#!/search/right">right</a>在途中

这也是可以接受的

这就是<a href="http://twitter.com/#!/search/right">#right</a>在途中

页面大量的#(hash)标签在不同的类和id

解决方案

var string = "This is going #right on the way";string.replace(/#(S*)/g,'<a href="http://twitter.com/#!/search/$1">$1</a>')

演示: http://jsfiddle.net/dKm82/

How to change # tag + Character to link using javascript

This is going #right on the way

with

This is going <a href="http://twitter.com/#!/search/right">right</a> on the way

even this is also acceptable

This is going <a href="http://twitter.com/#!/search/right">#right</a> on the way

The page lots's of # (hash) tag in different classes and id's

解决方案

var string = "This is going #right on the way";
string.replace(/#(S*)/g,'<a href="http://twitter.com/#!/search/$1">$1</a>')

Demo: http://jsfiddle.net/dKm82/

这篇关于在页面加载时将#hash 标签更改为链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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