更改#hash 标记以链接页面加载

2022-01-18 00:00:00 tags hyperlink jquery javascript

如何使用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/

相关文章