<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled</title>
<script>
function test(o) {
if (!o.checked) {
return;
}
var checks = document.getElementsByName("checkbox");
var tr = o.parentNode.parentNode;
console.log(tr.length);
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" name="checkbox" οnclick="test(this);"/></td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
<td><input type="checkbox" name="checkbox" οnclick="test(this);"/></td>
</tr>
</tbody>
</table>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled</title>
<script>
function test(o) {
if (!o.checked) {
return;
}
var checks = document.getElementsByName("checkbox");
var tr = o.parentNode.parentNode;
console.log(tr.length);
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" name="checkbox" οnclick="test(this);"/></td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
<td><input type="checkbox" name="checkbox" οnclick="test(this);"/></td>
</tr>
</tbody>
</table>
</body>
</html>