日期:2014-05-17  浏览次数:20650 次

jquery 扩展 去除字符串中的html代码

/**
?* jquery去除字符串中的html
?* 示例:
?* ??? var a="<b>abc</b>";
?* ??? $.removeHtml(a);
?* 结果:abc
?*/
jQuery.removeHtml = function(s){
??? return (s)? jQuery("<p>").append(s).text(): "";
}

?

测试方法:

?

var a="<b>abc</b>";
a=$.removeHtml(a);
alert(a);