curRow = event.srcElement.parentElement.rowIndex;
var_filename = document.all.store_content.rows[curRow].cells[0].innerText;
curRow的值增加2??
curRow+2即可
var_filename = document.all.store_content.rows[curRow].cells[0].innerText;
curRow的值增加2??
curRow+2即可
至少这样不可以:var_filename = document.all.store_content.rows[curRow+2].cells[0].innerText;
我已经试过啦,所以来问的。
parseInt(curRow)+parseInt(2)
这句话应该有问题。
event.srcElement未必是td,你得向上遍历
<script language="javascript">
function getFileName()
{
var var_filename;
curRow = event.srcElement
while(curRow.tagName!="TR")
curRow=curRow.parentElement
if(curRow.tagName!="TR") return
curRow=curRow.rowIndex;
var_filename = document.all.store_content.rows[curRow].cells[0].innerText;
alert(var_filename);
if(document.all.store_content.rows[curRow+2])
{
var_filename = document.all.store_content.rows[curRow+2].cells[0].innerText;
alert(var_filename);
}
}
</script>
<table id=store_content border=0 onclick="getFileName()">
<tr>
<td>1</td><td>1</td><td>aaa</td>
</tr>
<tr>
<td>2</td><td>aaa</td><td>aaa</td>
</tr>
<tr>
<td>3</td><td>aaa</td><td>aaa</td>
</tr>
<tr>
<td>4</td><td>aaa</td><td>aaa</td>
</tr>
</table>