<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function getrow(obj)
{
if(event.srcElement.tagName == "TD"){
curRow = event.srcElement.parentElement;
alert("这是第 " + (curRow.rowIndex+1) + " 行");
if(confirm("是否删除改行?")) {
document.all.myTable.deleteRow(curRow.rowIndex);
}
}
}
</script>
<BODY>
<FORM METHOD=POST ACTION="" name="myForm" id="myForm">
判断鼠标点击表格额行数及是否删除该行
<table name="myTable" id="myTable" border="1" width="100%" onclick=getrow(this)>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
<tr>
<td width="50%">1</td>
<td width="50%">1</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
评论4
最新资源