Create/parse links from text in jQuery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $.fn.clickUrl = function() {
  2. var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
  3. this.each(function() {
  4. $(this).html(
  5. $(this).html().replace(regexp,'<a href="$1">$1</a>')
  6. );
  7. });
  8. return $(this);
  9. }

URL: http://devkick.com/blog/parsing-strings-with-jquery/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.