oe*********@gmail.com wrote:
Having a bit of trouble figuring out how to get the innerText of
a cell other that the one selected.
Here's a cross-browser example. If you want innerText (what's MSIE
propietary), use `sText = oTD.innerText´ instead.
function foo(oEvent) {
var oTR, oParent, oTD, oTN;
if ((oTR = oEvent.target || oEvent.srcElement)) {
while (oTR.tagName != "TR" && (oParent = oTR.parentNode)) {
oTR = oParent;
}
if (oTR.cells && (oTD = oTR.cells[2])) {
sText = (oTN = oTD.firstChild) && oTN.nodeType == 3 && oTN.nodeValue;
alert(sText || "not found");
}
}
}
[...]
<table>
<tbody onclick="foo(event)">
<tr>
<td>A1</td><td>A2</td><td>A3</td>
</tr>
<tr>
<td>B1</td><td>B2</td><td>B3</td>
</tr>
<tr>
<td>C1</td><td>C2</td><td>C3</td>
</tr>
</tbody>
</table>