<!DOCTYPE html
>
<html lang
="en">
<head
>
<meta charset
="UTF-8">
<meta name
="viewport" content
="width=device-width, initial-scale=1.0">
<title
>课时
1</title
>
</head
>
<body
>
<div
class="box" id
="box" style
="background-color: green">
我是文本节点
<!-- 我是注释君
-->
<h1
>我是标题标签
</h1
>
<a href
="">我是超链接
</a
>
<p
>我是段落标签
</p
>
</div
>
<script type
="text/javascript">
var div
= document
.getElementsByTagName('div')[0];
function elemChildren(node
){
var temp
= {
'length': 0,
'push': Array
.prototype
.push
,
'splice': Array
.prototype
.splice
},
len
= node
.childNodes
.length
;
for(var i
= 0; i
< len
; i
++){
var childItem
= node
.childNodes
[i
];
if(childItem
.nodeType
=== 1){
temp
[temp
['length']] = childItem
;
temp
['length']++;
}
}
return temp
;
}
console
.log(elemChildren(div
));
</script
>
</body
>
</html
>
<!DOCTYPE html
>
<html lang
="en">
<head
>
<meta charset
="UTF-8">
<meta name
="viewport" content
="width=device-width, initial-scale=1.0">
<title
>课时
1</title
>
</head
>
<body
>
<div
class="box" id
="box" style
="background-color: green">
我是文本节点
<!-- 我是注释君
-->
<h1
>我是标题标签
</h1
>
<a href
="">我是超链接
</a
>
<p
>我是段落标签
</p
>
</div
>
<script type
="text/javascript">
var div
= document
.getElementsByTagName('div')[0];
function elemChildren(node
){
var temp
= {
'length': 0,
'push': Array
.prototype
.push
,
'splice': Array
.prototype
.splice
},
len
= node
.childNodes
.length
;
for(var i
= 0; i
< len
; i
++){
var childItem
= node
.childNodes
[i
];
if(childItem
.nodeType
=== 1){
temp
[temp
['length']] = childItem
;
temp
['length']++;
}
}
return temp
;
}
console
.log(elemChildren(div
));
</script
>
</body
>
</html
>
<!DOCTYPE html
>
<html lang
="en">
<head
>
<meta charset
="UTF-8">
<meta name
="viewport" content
="width=device-width, initial-scale=1.0">
<title
>课时
1</title
>
</head
>
<body
>
<div
class="box" id
="box" style
="background-color: green">
我是文本节点
<!-- 我是注释君
-->
<h1
>我是标题标签
</h1
>
<a href
="">我是超链接
</a
>
<p
>我是段落标签
</p
>
</div
>
<script type
="text/javascript">
var div
= document
.getElementsByTagName('div')[0];
function elemChildren(node
){
var temp
= {
'length': 0,
'push': Array
.prototype
.push
,
'splice': Array
.prototype
.splice
},
len
= node
.childNodes
.length
;
for(var i
= 0; i
< len
; i
++){
var childItem
= node
.childNodes
[i
];
if(childItem
.nodeType
=== 1){
temp
.push(childItem
);
}
}
return temp
;
}
console
.log(elemChildren(div
));
</script
>
</body
>
</html
>
转载请注明原文地址: https://lol.8miu.com/read-29088.html