jQuery add attribute when a certain text string is found
My issue is that I have a group of tweets being called in with jQuery, but its calling them in all as plain text. My goal would be to have any thing with an http:// automatically linked. In this case, something like this:
<a href="{link}"> {link} </a>
With {link} 开发者_JAVA百科being replaced with the actual link inserted. For example, if I have a tweet that says, "Visit this cool link! http://foo.com/" I'd want the link to actually work, as right now its just plain text, and therefore not clickable.
Thanks in advance! :)
EDIT: Here's a link to what I have so far. http://jsfiddle.net/Remixz/uCk4s/
Have a look at this accepted answer to this question: How to replace plain URLs with links?
I think that does exactly what you are looking for.
I've forked the plug-in you were using on github and made an update to it to include the linkify function. Here's a demo of the updated version in action: http://jsfiddle.net/Ender/CrzCZ/
And here's the updated plug-in on github: https://github.com/ender2021/jQuery-Tweets/raw/master/js/jquery.tweets.0.1.js
精彩评论