我正在更新文本值,我不確定爲什麼第一個代碼塊不起作用,但是備用塊會這樣。誰可以給我解釋一下這個?它們看起來相當。瞭解獲取和設置nodeValue
//不更新
newAtomicNum = 2;
oldAtomicNum = document.getElementById("atomicNumber").firstChild.nodeValue;
oldAtomicNum = newAtomicNum;
* 與 * //不更新
newAtomicNum = 2;
oldAtomicNum = document.getElementById("atomicNumber");
oldAtomicNum.firstChild.nodeValue = newAtomicNum;
所以我需要創建一個對節點的引用,然後才能設置它? – awpawluczkowycz