您好
請問
我動態產生TR跟TD如下
for (var i = 0; i < 5; i++) {
var oRow = oTable.insertRow(oTable.rows.length);
var aRows = oTable.rows;
var aCells = oRow.cells;
var oCell_1 = aRows(oRow.rowIndex).insertCell(aCells.length);
var oCell_2 = aRows(oRow.rowIndex).insertCell(aCells.length);
var oBuildingNode = document.createElement("INPUT");
oBuildingNode.type = 'checkbox';
oBuildingNode.id = BuildingID;
oCell_1.appendChild(oBuildingNode);
oCell_2.style.color = "Blue";
oCell_2.innerText = BuildingName;
oCell_2.onmouseover = function() {
oCell_2.style.cursor = "hand";
oCell_2.style.color = "Orange";
}
oCell_2.onmouseout = function() {
oCell_2.style.cursor = "pointer";
oCell_2.style.color = "Blue";
}
}
我認為五個TR的TD都應該有onmouseon和onmouseout事件
可是結果是
只有第五個TR的TD才有onmouseon和onmouseout
請問我哪裏錯了