在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ HTML中,如何去掉某個元素下的一些特殊標簽?

HTML中,如何去掉某個元素下的一些特殊標簽?

如題,我們有一個Node元素的innerHTML是這樣的:

<div>These vignettes illustrate different consequences of scarcity capturing attention. In the previous chapter, we saw how tunneling distorts the trade-offs we make. Trying to focus on making <text>ends</text> meet right now, we fail to consider the impact in the future of raising the insurance deductible. In the vignettes above, in contrast, we catch people as they are trying to focus on something unrelated to their immediate scarcity. We catch the harried executive not when she is <text>putting</text> together her sales pitch but when she is a parent. We catch the student not when he is dealing with making ends meet but when he is trying to focus on his exam. </div>

其中,有兩個<text></text>標簽,請問有什么方法可以低成本的去掉他們?
多謝

回答
編輯回答
氕氘氚
function removeMark(mark,str){
    if(!mark || !str) return false;
    
    var reg = new RegExp("\\<\/?"+mark+".*?\\>","g");
        
    if(reg.test(str)){
        return str.replace(reg,"");
    }else{
        return str;
    }
}

可以去除 <text></text> 或者 <br /> 這樣的標簽

alert(1)

2017年7月6日 09:25
編輯回答
痞性
str.replace(/<text.*?>.*?<\/text>/,"")
$("text").remove()
2017年8月6日 00:23