Blogger Information
Blog 250
fans 3
comment 0
visits 322916
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
JS-属性/节点的获取
梁凯达的博客
Original
1272 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div></div>
	<ul id="uls">
		<li>1</li>
		<li>2</li>
		<!-- 今天天气挺好的!!! -->
		<li id="demo">3</li>
		<li>4</li>
		<li>5</li>
	</ul>
</body>
<script>
//alert(document.documentElement.nodeName);
//alert(document.body.nodeName);
//测试元素节点
var uls = document.getElementById('uls');
//alert(uls.nodeName);
//alert(uls.firstChild.nodeName);
//alert(uls.lastChild.nodeName);
//console.log(uls.childNodes);
console.log(uls.children[0]);
</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post