gpt4 book ai didi

javascript - 检索和设置文本节点值的属性 : data or nodeValue?

转载 作者:行者123 更新时间:2023-11-30 06:40:25 25 4
gpt4 key购买 nike

我应该使用哪一个?

http://reference.sitepoint.com/javascript/CharacterData/data

http://reference.sitepoint.com/javascript/Node/nodeValue

该站点建议使用 nodeValue,但显示数据具有更好的兼容性。

最佳答案

只使用nodeValue,因为数据指定它与nodeValue相同。

页面阐明:

The nodeValue property is the best way of manipulating the value of nodes - preferable over more specialized properties, such as data or value, because of various browser issues.

这是关于该主题的另一个讨论的一个很好的答案:

The nodeValue field is defined for all Nodes and maps to different things depending on the node type. The data field is defined on Nodes that inherit from CharacterData, which is to say Text, CDATASection, and Comment nodes. For those three node types, nodeValue maps straight to data. I know it's weird, but the DOM does have quite a few such irrelevant duplication due to trying to make the vendors happy back then.

http://tech.groups.yahoo.com/group/svg-developers/message/53314

关于javascript - 检索和设置文本节点值的属性 : data or nodeValue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11706643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com