js怎么去掉<p>32323232<p>中的<p>标签只要32323232 ? 求高手帮忙!

JavaScript011

js怎么去掉<p>32323232<p>中的<p>标签只要32323232 ? 求高手帮忙!,第1张

用正则表达式

<script type="text/javascript">

var a = "<p>32323232</p>"

var b = a.replace(/<.*?>/ig,"")

alert(b)

</script>

<script type="text/javascript">

var divNode = document.getElementById('list_title')

for (var i = divNode.children.length - 1i >= 0 i--) {

if (divNode.children[i].nodeName == 'P') {

divNode.removeChild(divNode.children[i])

}

}

</script>