We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOM可以将任何HTML描绘成一个由多层节点构成的结构。节点分为12种不同类型,每种类型分别表示文档中不同的信息及标记。
每个节点都拥有各自的特点、数据和方法,也与其他节点存在某种关系。
节点之间的关系构成了层次,而所有页面标记则表现为一个以特定节点为根节点的树形结构。
在var nodeTagName = obj.nodeName.toLowerCase();中的.toLowerCase()的作用是将nodeName返回值变成小写。(一般nodeName的返回值为大写)
<script> var divNode = document.getElementById("container"); if (divNode.nodeType == 1){ //判断是否为元素节点 alert("Node is an element."); } console.log(divNode.nodeName + "//" + divNode.nodeValue); var attrNode = divNode.attributes[1]; console.log(attrNode.nodeName + "//" + attrNode.nodeValue); var textNode = divNode.childNodes[0]; //获取第一个子元素节点 console.log(textNode.nodeName + "//" + textNode.nodeValue); var commentNode = document.body.childNodes[1]; console.log(commentNode.nodeName + "//" + commentNode.nodeValue); console.log(document.doctype.nodeName + "//" + document.doctype.nodeValue); var frag = document.createDocumentFragment(); console.log(frag.nodeName + "/" + frag.nodeValue); if (divNode.nodeType == 1){ alert("Node is an element."); } </script>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
DOM可以将任何HTML描绘成一个由多层节点构成的结构。节点分为12种不同类型,每种类型分别表示文档中不同的信息及标记。
每个节点都拥有各自的特点、数据和方法,也与其他节点存在某种关系。
节点之间的关系构成了层次,而所有页面标记则表现为一个以特定节点为根节点的树形结构。
在var nodeTagName = obj.nodeName.toLowerCase();中的.toLowerCase()的作用是将nodeName返回值变成小写。(一般nodeName的返回值为大写)
The text was updated successfully, but these errors were encountered: