krr*_*r25 28 javascript jquery
我有这个代码:
var content = "<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>";
我想从上面的字符串中删除所有<p>和</p>标签.只想显示没有html标签的字符串值,如:
"Dear sms, This is a test notification for push message from center II."
Ble*_*der 63
为什么不让jQuery这样做呢?
var content = "<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>";
var text = $(content).text();
Hum*_*ing 26
这是我的解决方案,
function removeTags(){
    var txt = document.getElementById('myString').value;
    var rex = /(<([^>]+)>)/ig;
    alert(txt.replace(rex , ""));
}
使用普通的javascript:
content = content.replace(/(<p>|<\/p>)/g, "");
| 归档时间: | 
 | 
| 查看次数: | 75511 次 | 
| 最近记录: |