我知道我可以使用 nodeValue 来更改文本中的文本,element.firstChild.nodeValue = text
但我可以使用 setAttribute 来做同样的事情吗?
HTML :
<p id="description">Some text here.</p>
Run Code Online (Sandbox Code Playgroud)
JS:
var description = document.getElementById("description");
description.setAttribute(nodeValue, text);
Run Code Online (Sandbox Code Playgroud)
它不起作用。这是否意味着“nodeValue”不是元素的属性?
javascript ×1