<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0">

<style>

div{ margin:0 auto;padding:0; }
a{ display:block;width:300px;line-height:20px;font-family:microsoft yahei; }
</style>
<title></title>
</head>
<body>

<div )



//方法二:
<script type="text/javascript">
// 使用 children 的用法
window.onload = function (){
var arr = document.getElementById("demo2").children;
var str ="";
for(var i=0;i<arr.length;i++){
str += "第"+(i+1)+"个文本节点的内容"+ arr[i].firstChild.nodeValue +"\n";
}
console.log(str);
}
</script>

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-04-30
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-27
  • 2021-06-07
  • 2022-12-23
  • 2021-12-18
  • 2021-05-21
相关资源
相似解决方案