2 回答

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊
<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>
不知道這個(gè)能不能滿足要求,注意這個(gè)demo用到了jquery.

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
lz就是想給選中的項(xiàng)添加編號了?思路就是這樣的:你肯定可以獲取選中的行,當(dāng)然你需要預(yù)定義一個(gè)容器(div,span...)來顯示編號,你肯定可以獲取當(dāng)前行的那個(gè)span,然后外層的循環(huán)變量不就是你想要的編號?
添加回答
舉報(bào)