replace(/[0-9]/g,"")
将所有数字替换为空,g表示全局匹配即匹配所有srcElement 事件触发的源,window.event.srcElement
parentElement 其上一级元素,td的上一级为tr,tr的上一级为tbody等
cellIndex td相对其所在tr的索引
rowIndex tr相对其所在tbody(table)的索引
将所有数字替换为空,g表示全局匹配即匹配所有srcElement 事件触发的源,window.event.srcElement
parentElement 其上一级元素,td的上一级为tr,tr的上一级为tbody等
cellIndex td相对其所在tr的索引
rowIndex tr相对其所在tbody(table)的索引
function document.onclick(){
var e=window.event.srcElement
switch(e.tagName){
case "INPUT":
var i=e.sourceIndex-e.parentElement.sourceIndex
var c=e.parentElement.cellIndex
var r=e.parentElement.parentElement.rowIndex
alert(".rows[" + r + "].cells[" + c + "].children[" + i + "]");
break;
case "TD":
var c=e.cellIndex
var r=e.parentElement.rowIndex
alert(".rows[" + r + "].cells[" + c + "]");
break;
case "TR":
var r=e.rowIndex
alert(".rows[" + r + "]");
}
}
</script>
<table width=915 height="137" id="tab1" border="1">
<tr rowspan=3 align=center class=tr1>
<td width="96" rowspan="3" align="center" height="1">大点</td>
<td rowspan="2" align="center" height="1" width="38">数量合计</td>
<td colspan="7" align="center" height="3" width="314">无周期</td>
<td colspan="2" align="center" height="3" width="98">无周期</td>
<td colspan="5" align="center" height="3" width="280">无周期</td>
<td width="55" rowspan="3" height="1">备注</td>
<tr rowspan=3 align=center class=tr1>
<td colspan="2" align="center" height="1" width="86">无周期</td>
<td colspan="2" align="center" height="1" width="87">无周期</td>
<td colspan="2" align="center" height="1" width="92">无周期</td>
<td width="45" align="center" height="1">无期</td>
<td width="47" align="center" height="1">无期</td>
<td width="46" align="center" height="1">周期</td>
<td width="51" align="center" height="1">无周期</td>
<td width="50" align="center" height="1">无周期</td>
<td width="53" align="center" height="1">无周期</td>
<td width="47" align="center" height="1">无周</td>
<td align="center" height="1" width="59">无周期</td>
<tr rowspan=3 align=center class=tr1>
<td width="38" align="center" height="1">周期</td>
<td width="40" align="center" height="1">周期</td>
<td width="41" align="center" height="1">周期</td>
<td width="41" align="center" height="1">周期</td>
<td width="41" align="center" height="1">周期</td>
<td width="41" align="center" height="1">周期</td>
<td width="46" align="center" height="1">周期</td>
<td width="45" align="center" height="1">周期</td>
<td width="47" align="center" height="1">周期</td>
<td width="46" align="center" height="1">周期</td>
<td width="51" align="center" height="1">周期</td>
<td width="50" align="center" height="1">周期</td>
<td width="53" align="center" height="1">周期</td>
<td width="47" align="center" height="1">周期</td>
<td align="center" height="1" width="59">周期</td>
<tr align=center>
<td width="96" height="26" > 点</td>
<td width="38" height="26" ><input size=5 value="" ></td>
<td width="40" height="26" ><input size=5 value="" ></td>
<td width="41" height="26" > </td>
<td width="41" height="26" ><input size=5 value="" ></td>
<td width="41" height="26" > </td>
<td width="41" height="26" ><input size=5 value="" ></td>
<td width="46" height="26" ><input size=5 value="" ></td>
<td width="45" height="26" > </td>
<td width="47" height="26" ><input size=5 value="" ></td>
<td width="46" height="26" > </td>
<td width="51" height="26" ><input size=6 value="" ></td>
<td width="50" height="26" ><input size=6 value="" ></td>
<td width="53" height="26" ><input size=6 value="" ></td>
<td width="47" height="26" ><input size=5 value="" ></td>
<td width="59" height="26" > </td>
<td width="55" height="26" ><input size=6 value=""></td>
</tr>
<tr align=center>
<td width="96" height="26" > 点</td>
<td width="38" height="26" ><input size=5 value="" ></td>
<td width="40" height="26" ><input size=5 value="" ></td>
<td width="41" height="26" ><input size=5 value="" ></td>
<td width="41" height="26" ><input size=5 value="" ></td>
<td width="41" height="26" > </td>
<td width="41" height="26" ><input size=5 value="" ></td>
<td width="46" height="26" ><input size=5 value="" ></td>
<td width="45" height="26" > </td>
<td width="47" height="26" ><input size=5 value="" ></td>
<td width="46" height="26" > </td>
<td width="51" height="26" ><input size=6 value="" ></td>
<td width="50" height="26" ><input size=6 value="" ></td>
<td width="53" height="26" > </td>
<td width="47" height="26" ><input size=5 value="" ></td>
<td width="59" height="26" ><input size=5 value="" ></td>
<td width="55" height="26" ><input size=6 value=""></td>
</tr>
</table>
srcElement 事件的来源元素
parentElement 父元素
cellIndex 某个单元格在该行内的序号(从0开始)
rowIndex 某一行在表格中的行号(从0开始)
和[0-9]/g 正则表达式,表示0-9这10个字符假如你的表格id=tab1,则
tab1.rows返回一个集合,包含表格中的所有行
tab1.rows(0) 返回表格中的第一行
tab1.rows(0).cells 返回表格中第一行中的单元格的集合
tab1.rows(0).cells(1) 返回第一行第2个单元格
tab1.rows.length表示 表格的行数
tab1.rows(1).cols.length 表格第2行的单元个数