2 回答

TA贡献1843条经验 获得超7个赞
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<table id="table1">
<tr>
<td> <input type="checkbox" value="选择"/></td>
<td><input type="text" /></td>
</tr>
<tr>
<td> <input type="checkbox" value="选择"/></td>
<td><input type="text" /></td>
</tr>
<tr>
<td> <input type="checkbox" value="选择"/></td>
<td><input type="text" /></td>
</tr>
<table>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#table1 input[type='checkbox']").click(function(){
$("#table1 input[type='text']").attr("innerText","");
var index = 1;
$("#table1 input:checked").each( function(i){
var chkbox = $(this);
chkbox[0].parentElement.parentElement.children(1).children(0).innerText = index;
index++;
});// end each
});// end click
}); // end ready事件
</script>
</html>
不知道这个能不能满足要求,注意这个demo用到了jquery.

TA贡献1813条经验 获得超2个赞
lz就是想给选中的项添加编号了?思路就是这样的:你肯定可以获取选中的行,当然你需要预定义一个容器(div,span...)来显示编号,你肯定可以获取当前行的那个span,然后外层的循环变量不就是你想要的编号?
添加回答
举报