我有javascript函數如下:試圖增加HTML節點,但它不會出現
function addConfirmLine(number, strItem, strValue) {
var confirmLine = document.getElementById("divConfirmation").appendChild(document.createElement("div"));
confirmLine.id = "divConfirmLine" + number;
var confirmItem = confirmLine.appendChild(document.createElement("div"));
confirmItem.className = "confirmItem";
confirmItem.nodeValue = strItem;
var confirmValue = confirmLine.appendChild(document.createElement("div"));
confirmValue.className = "confirmValue";
confirmValue.nodeValue = strValue;
}
和div
這樣
<div id="divConfirmation">
<div class="checkHead">
Check the following details. Click "Prev" to make corrections. Click "Upload" to process and upload the sermon.
</div>
</div>
這樣做的目的是什麼落得像這樣:
<div id="divConfirmation">
<div class="checkHead">
Check the following details. Click "Prev" to make corrections. Click "Upload" to process and upload the sermon.
</div>
<div id="divConfirmLine1">
<div class="confirmItem">Item1</div>
<div class="confirmValue">Value1</div>
</div>
<div id="divConfirmLine2">
<div class="confirmItem">Item2</div>
<div class="confirmValue">Value2</div>
</div>
</div>
問題是行不通的。新的div
沒有出現,我也沒有收到任何錯誤。我究竟做錯了什麼?
您測試過哪些瀏覽器?它可以在任何或沒有的情況下工作? – acrosman 2010-09-24 13:17:28
它在IE8中運行的HTA中 – 2010-09-24 13:19:25
剛剛在Firefox中以與.htm相同的結果嘗試過它 – 2010-09-24 13:23:04