var row=obj.rowIndex;
var cell=obj.cellIndex;
前提需要得到该行或者列对象
var cell=obj.cellIndex;
前提需要得到该行或者列对象
解决方案 »
- JS如何判断输入框(就是text或textarea)的值只是空字符串或只带空格得字符串
- 正则表达式如何匹配字符前的所有空格?
- ======== easyUI 中 tree 的精确定位 =======
- 用javascript写了个类,操作异步XMLHTTP的onreadystatechange时怎么取得类this指针
- 能不能改变鼠标右键的点击后的菜单显示?
- 在不知道文本框控件数量的情况下如何循环判断所有文本框中所填的值是否正确?
- 如何通过JavaScript获得客户端机器的计算机名?
- 请问:javascript:top.openBranch("我的网站")中的top是神末意思
- 求写一个停止移动的函数,大神来求我啊...苦逼新手
- js 调用诡异。
- 在线等 会ASP.NET的更好
- applet高手请进来看100分
<head><script language=javascript>
function a(o){
var col=o.parentNode.id;
var row=o.parentNode.parentNode.id;
alert("col:"+col+";row:"+row);
}
</script>
</head>
<body>
<table border=1 width="100">
<tr id="1"><td id="1" ><a href="#" onclick="a(this)">1</a></td><td id="2"><a href="#" onclick="a(this)">2</a></td></tr>
<tr id="2"><td id="1"><a href="#" onclick="a(this)">3</a></td><td id="2"><a href="#" onclick="a(this)">4</a></td></tr>
<tr id="3"><td id="1"><a href="#" onclick="a(this)">5</a></td><td id="2"><a href="#" onclick="a(this)">6</a></td></tr>
<tr id="4"><td id="1"><a href="#" onclick="a(this)">7</a></td><td id="2"><a href="#" onclick="a(this)">8</a></td></tr>
</table>
</body>
</html>
<head>
<title>new page</title>
<script language=javascript>
function a(obj){
var col=obj.parentNode.cellIndex;//列索引,初始值为0
var row=obj.parentNode.parentNode.rowIndex;//行索引,初始值为0
alert("col:"+col+";row:"+row);
}
</script>
</head>
<body>
<table border=1 width="100">
<tr>
<td><a href="#" onclick="a(this)">1</a></td>
<td><a href="#" onclick="a(this)">2</a></td>
</tr>
<tr>
<td><a href="#" onclick="a(this)">3</a></td>
<td><a href="#" onclick="a(this)">4</a></td>
</tr>
<tr>
<td><a href="#" onclick="a(this)">5</a></td>
<td><a href="#" onclick="a(this)">6</a></td>
</tr>
<tr>
<td><a href="#" onclick="a(this)">7</a></td>
<td><a href="#" onclick="a(this)">8</a></td>
</tr>
</table>
</body>
</html>