<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function myClick(e) {
// var cks = document.getElementsByTagName("ckname1");
// for (var i = 0; i < cks.length; i++) {
// if (e.checked) {
// alert(e.id);
// }
// }
if (e.checked) {
alert(e.id);
alert(e.mytest);
e.checked = !e.checked;
}
}
</script>
</head>
<body >
<table >
<tbody >
<tr><td id="testId">选中<input type="checkbox" id="ck1" mytest="test1" name="ckname1" οnclick="if(this.checked){alert('选中时:'+this.id);}else{alert('没有被选中');}" /></td><td><input type="text" id="Text1" /></td></tr>
<tr><td>选中<input type="checkbox" οnclick="myClick(this)" id="ck2" mytest="test2" name="ckname1" /></td><td><input type="text" id="Text2" /></td></tr>
<tr><td>选中<input type="checkbox" οnclick="myClick(this)" id="ck3" mytest="test3" name="ckname1" /></td><td><input type="text" id="Text3" /></td></tr>
<tr><td>选中<input type="checkbox" οnclick="myClick(this)" id="ck4" mytest="test4" name="ckname1" /></td><td><input type="text" id="Text4" /></td></tr>
</tbody>
</table>
</body>
</html>