<div id="lee">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
</div>
<script>
var x = document.getElementById(‘lee‘).childNodes
for (var i in x){
if(x[i].nodeType == 1){
console.log(x[i].nodeName+‘:‘+x[i].childNodes[0].nodeValue)
}
}
</script>
P:1
P:2
P:3
P:4
P:5
原文地址:http://blog.51cto.com/12173069/2085035