更改#hash 标记以链接页面加载 [英] Change #hash tag to link on page load

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

问题描述

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

How to change # tag + Character to link using javascript

This is going #right on the way

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

不同类别和id中的#(哈希)标签的页面

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>')

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

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

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