nodeValue属性
nodeValue属性是html dom中的一个属性,可以用来获取或设置节点的值。它的使用方法也比较简单,只需要使用node.nodeValue就可以获取节点的值,使用node.nodeValue=value即可设置节点的值。
节点值的类型
在html dom中,节点的值可以是各种类型,比如字符串、数字、布尔值等。
// 获取节点值 var nodeValue = node.nodeValue; // 设置节点值 node.nodeValue = value;
注意事项
- nodeValue属性只能用于文本节点,不能用于元素节点。
- nodeValue属性不支持IE8及以下的浏览器。