探索DOMNode

实现代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>exploreDOMNode</title>
<style>

</style>
</head>
<body>
<div id="myDiv">
<p>This is a Div element!</p>
</div>
<script>
var divNode = document.getElementById('myDiv');
//输出 DIV
console.info(divNode.nodeName);
//输出 1
console.info(divNode.nodeType);
//输出 This is a Div element!
console.info(divNode.innerText);
//输出 <p>This is a Div element!</p>
console.info(divNode.innerHTML);
</script>
</body>
</html>

页面效果

image

posted @ 2017-01-03 22:48  Jener_Yan  阅读(190)  评论(0编辑  收藏  举报