我有一個動態填充的表(使用更新面板),然後當用戶單擊選定的行時,所有數據都寫入標籤。在IE和Chrome中運行良好,但Firefox未定義。簡單的表格有5列。我動態綁定表具有以下內容:(請原諒的代碼膨脹)Firefox使用jquery讀取單元格元素時未定義的值
$('#tblResults').delegate(".aRow", "click", function() {
var thatID = this.id;
if (thatID != "0") {
var wordz = "";
var specialID = document.getElementById("hiddenChosenContact");
var targetContact = document.getElementById("theContactLabel");
for (var i = 1; i <= this.cells.length - 1; i++) {
if (i == this.cells.length - 1)
wordz = wordz + this.cells[i].innerText;
else
wordz = wordz + this.cells[i].innerText + " - ";
}
targetContact.innerHTML = wordz;
specialID.value = thatID;
}
else {
}
});
行給出負載ID和類名「AROW」。 我試過只使用完整的jquery,$(this),但說實話我不確定表操作的語法。
**編輯。對不起,意思是說,不定值包含this.cells內[I] .innerText
** HTML編輯
<table class="cvTableG" id="tblResults" cellPadding="0" cellSpacing="0" style="clear:left; width:100%; font-size:10px;">
<thead>
<tr class="aRow" id="1"><th width="14px;"> </th>
<th align="left" width="85px">Name</th>
<th align="left" width="90px">Surname</th>
<th align="left">Department</th>
<th align="left">Customer</th>
</tr>
</thead>
<tbody>
<tr class="aRow" id="2">
<td style="padding:0;"><input type="radio" name="myRadio" /></td>
<td>Marty</td>
<td>Elliott</td>
<td>Development Place</td>
<td>Rosebank</td>
</tr>
<tr class="aRow" id="3">
<td style="padding:0;"><input type="radio" name="myRadio" /></td>
<td>Sarah</td>
<td>Lee</td>
<td>Dev Place</td>
<td>JHB</td>
</tr>
<tr class="aRow" id="4">
<td style="padding:0;"><input type="radio" name="myRadio" /></td>
<td>Marty</td>
<td>Elliott</td>
<td>Halfway House</td>
<td>Durban</td>
</tr></tbody></table>
請與表格共享html片段。 – mnmnc 2012-07-31 08:21:23
以上編輯。道歉;) – 2012-07-31 08:28:59
['innerText'可能重複在IE瀏覽器,但不是在Firefox](http://stackoverflow.com/questions/1359469/innertext-works-in-ie-but-not-in-firefox) – Oriol 2015-11-29 20:15:28