jquery-text-tools: Link urls with jQuery
Here’s a little something I threw together today that is simple, yet a bit useful too. I’ve been working on an application that consumes text from a JSON service on the client side and populates the page with the results, in real time. Some of the snippets of text have links in them, so I wanted something quick and easy to “linkify” any urls that are contained within the text. The result is this:
var linkifiedHtml = $.link("Go to http://www.google.com to search");
Which simply puts an anchor around the contained url. You can also use CSS selectors too… say you want to linkify every paragraph with the class foo:
$('p.foo').link();
That pretty much sums it up. Go grab it off github and feel free to fork it/add to it.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!














April 18th, 2009 at 5:16 pm
[...] Carr created an interesting jQuery plugin: Link URLS with jQuery This will scan text for URLs and create proper links out of them. I’ve done this in ColdFusion for [...]