我有一个动态填充的表(使用更新面板),然后当用户单击所选行时,所有数据都将写入标签。在 IE 和 chrome 中运行良好,但 firefox 说未定义。有 5 列的简单表格。我使用以下内容动态绑定到表:(请原谅代码膨胀)
$('#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>