从javascript字符串中删除HTML标记

从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();