<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Js选中checkbox后获取table内一行TD所有数据-www.jb200.com</title>
<script>
function test(o) {
if (!o.
checked) {
return;
}
var tr = o.parentNode.parentNode;
var tds = tr.cells;
var str = "you click ";
for(var i = 0;i < tds.length;i++){
if (i < 3) {
str = str + tds[i].innerHTML + "--";
}
}
alert(str);
}
</script>
</head>
<body>
<table width="60%" cellspacing="0" cellpadding="0" align="left" border="1" bordercolordark="#ffffff" bordercolorlight="#B3B5B4" >
<tbody id="tabstore1">
<tr>
<td>b1</td>
<td>b2</td>
<td>b3</td>
<td><input type="checkbox" onclick="test(this);"/></td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3-脚本学堂</td>
<td><input type="checkbox" onclick="test(this);"/></td>
</tr>
</tbody>
</table>
</body>
</html>