从javascript字符串中删除HTML标记 [英] Remove HTML tags from a javascript string
本文介绍了从javascript字符串中删除HTML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码:
var content = "<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>";
我要删除所有< p>
和< / p>
来自上述字符串的标签。只想显示没有html标签的字符串值,如:
and I want to remove all <p>
and </p>
tags from the above string. Just want to display the string values without html tags like :
"Dear sms, This is a test notification for push message from center II."
推荐答案
为什么不让jQuery这样做?
Why not just let jQuery do it?
var content = "<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>";
var text = $(content).text();
这篇关于从javascript字符串中删除HTML标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文