求过滤html标签和CSS样式表的正则表达式!

html-css063

求过滤html标签和CSS样式表的正则表达式!,第1张

先过滤样式表之后再过滤html标签

过滤样式表用

<STYLE>[/s/S]*<\/STYLE>

然后再用<.[^>]*>过滤其他标签HTML

我封装成了函数,直接调用就可以了

function Dis(){

var allDiv=document.getElementsByTagName("div")

for(var i=0,len=allDiv.lengthi<leni ){

var reg = /^(post_)(\d*)$/

if(reg.test(allDiv[i].getAttribute("id"))){

var allSub=allDiv[i].getElementsByTagName("a")

for(var j=0,zen=allSub.lengthj<zenj ){

if(allSub[j].getAttribute("class")=="xw1"){

allDiv[i].style.display ="none"

}

}

}

}

}