参考:范仁义
js代码:
function filter(text) { var reg = /<[^<>]+>/g;//1、全局匹配g肯定忘记写,2、<>标签中不能包含标签实现过滤html标签 text = text.replace(reg, '');//替换html标签 text = text.replace(/ /ig, '');//替换html空格 return text; };
在angularjs中使用过滤器过滤富文本数据
app.filter('qxhtml', function () { return function (text) { var reg = /<[^<>]+>/g; text = text.replace(reg, ''); text = text.replace(/ /ig, ''); if (text.length > 50) { text = text.substring(0, 50) + "..."; } return text; }; });
使用过滤器
<div class="desc"> {{y.description| qxhtml}} </div>
如对本文有疑问, 点击进行留言回复!!
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
CTF 刷题记录(一) 白云新闻搜索(手动与自动化SQL注入)
javascript如何使用函数random来实现课堂随机点名方法详解
网友评论