DOM 탐색을 설명하기 위해 다음 페이지를 작성했습니다.
<html>
<head>
<title>DOM Traversal</title>
</head>
<body>
<div>
<p>Sample paragraph</p>
</div>
<h1>Sample H1</h1>
<script>
// Traversing the DOM tree
"use strict";
var node = document.body;
document.addEventListener("DOMContentLoaded", function (event) {
while(node) {
console.log(node);
node = node.firstChild;
}
}, false);
</script>
</body>
</html>
나에 따르면 출력은 body-> div-> p 여야하지만 body-> #text입니다. 누군가 #text가 무엇이며 원하는 주문을받지 못하는 이유를 설명 할 수 있습니까?
그것들은 "빈 텍스트"노드이며 여기에 블로그를 올렸습니다.
https://weblogs.asp.net/stevewellens/secret-covert-hush-hush-white-space-in-the-dom-exposed
http://www.w3.org/DOM/faq.html#emptytext에 설명되어 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다