- $(function() {
- $.fn.manhuaAutoURL = function(options) {
- var defaults = {
- Event : "click", //触发响应事件
- showId : "show" //显示内容容器ID
- };
- var options = $.extend(defaults,options);
- var $this = $(this); //当然响应事件对象
- var $show = $("#"+options.showId); //显示内容对象
- var $reg = /(http:\\/\\/|https:\\/\\/)((\\w|=|\\?|\\.|\\/|&|-)+)/g;
- //文本域绑定事件
- $this.live(options.Event,function(e){
- var content = $this.val();
- content = content.replace($reg, "<a href='$1$2'>$1$2</a>").replace(/\\n/g, "<br />");
- $show.html(content);
- });
- }
- });
- //该片段来自于http://www.codesnippet.cn/detail/100720134534.html
来源: http://www.codesnippet.cn/detail/100720134534.html