Created
October 21, 2010 12:48
-
-
Save Takazudo/638418 to your computer and use it in GitHub Desktop.
$.fn.autolink
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $.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