这是我所拥有的:
我即时创建此标记:
<p id="amount"><span></span></p>
现在我需要填充跨度:
if (amount.firstChild.nodeType == 1) {
amount.firstChild.nodeValue = text;
alert(description.firstChild.nodeType); //this shows SPAN
}
amount 是使用 getElementbyId 创建的变量,text 是一个可以工作并仅显示数字的变量。
现在,为什么不接受文本作为值?它呈现并为空跨度...并且文本工作正常...
非常感谢大家!
最佳答案
关于Javascript nodeValue 不接受新变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10487356/