Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created October 21, 2010 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Takazudo/638418 to your computer and use it in GitHub Desktop.
Save Takazudo/638418 to your computer and use it in GitHub Desktop.
$.fn.autolink
/**
* $.fn.autolink
* wrap a element for each http://~ text inside the dom
*/
$.fn.autolink = function(){
return this.each(function(){
var $el = $(this);
var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
$el.html( $el.html().replace(re, '<a href="$1">$1</a> ') );
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment