ITeye博客

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

dh189 · 2010-07-24 13:20 · jquery · Web前端 · Markdown


/**
 * 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);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。