36、Node对象的属性
程序员文章站
2022-06-13 13:01:57
...
属性一:标签节点、属性节点、文本节点
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<span id="spanId">嘻嘻哈哈</span><hr/>
</body>
<script type="text/javascript">
//获取标签对象
var span1 = document.getElementById("spanId");
document.write("nodeType:"+span1.nodeType+", ");
document.write("nodeName:"+span1.nodeName+", ");
document.write("nodeValue:"+span1.nodeValue+", ");
document.write("<hr/>");
//获取属性对象
var id1 = span1.getAttributeNode("id");
document.write("nodeType:"+id1.nodeType+", ");
document.write("nodeName:"+id1.nodeName+", ");
document.write("nodeValue:"+id1.nodeValue+", ");
document.write("<hr/>");
//获取文本对象
var text1 = span1.firstChild;
document.write("nodeType:"+text1.nodeType+", ");
document.write("nodeName:"+text1.nodeName+", ");
document.write("nodeValue:"+text1.nodeValue+", ");
document.write("<hr/>");
</script>
</html>
属性二:父节点、子节点、同辈节点
上一篇: Spring依赖注入的模式和类型
下一篇: 结构型模式之组合模式composite