这段代码用于清除指定元素对象内的html代码,相当于stripHtml函数,代码被定义成了jquery插件的形式,调用起来非常方便。
- (function($) {
- $.fn.stripHtml = function() {
- var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
- this.each(function() {
- $(this).html( $(this).html().replace(regexp,'') );
- });
- return $(this);
- }
- })(jQuery);
- $('p').stripHtml();
来源: http://www.phpxs.com/code/1003674/