[JavaScript] jQuery使用一个固定连接替换指定标签内的所有连接 →→→→→进入此内容的聊天室

来自 , 2019-07-23, 写在 JavaScript, 查看 127 次.
URL http://www.code666.cn/view/94739e5a
  1. $.fn.replaceUrl = function() { 
  2.        //http://www.sharejs.com
  3.   var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; 
  4.   return this.each(function() { 
  5.     $(this).html( 
  6.       $(this).html().replace(regexp,'<a href="$1">$1</a>')
  7.     ); 
  8.   });
  9. } 
  10. //用法  
  11. $('p').replaceUrl(); 
  12. //javascript/8881

回复 "jQuery使用一个固定连接替换指定标签内的所有连接"

这儿你可以回复上面这条便签

captcha