using a twitter display widget and need to add links to the hash tags. so i need a pattern replacement, replacing each string that starts with a hash/pound sign and ends in a space with the twitter search link. i am pretty clumsy w/jquery--can someone point me in the right direction -- thanks, anyone!
something taking me:
// FROM:
<ul id="tweets">
<li>Some nutty tweet. #nutty</li>
<li>A fruity tweet here. #fruity</li>
</ul>
// TO:
<ul id="tweets">
<开发者_如何学运维;li>Some nutty tweet. <a href="http://twitter.com/search?q=%23nutty">#nutty</a></li>
<li>A fruity tweet here. http://twitter.com/search?q=%23fruity">#fruity</a></li>
</ul>
Since you are using jQuery, I would recommend the jQuery Tweetify Text from the CSS-Snippets library.
You would then use it like this (given your code):
$("#tweets li").tweetify();
In addition to matching #hashes
, it also turns URL's into hyperlinks, and matches @username
and links to their profile.
精彩评论