一般做法是,用户操作完成后,对Table内所有checkbox做一个循环取,但是考虑效率,可以在客户每次check时,记录下checkbox为checked的值到一个数组中,更改操作时,同步更新这个数组。 <table id="tbl" width="200px" border="1"> <tr> <td><input type="checkbox" title="1" οnclick="onCheck(this)"/></td> <td>a</td> <td>a</td> </tr> <tr> <td><input type="checkbox" title="2" οnclick="onCheck(this)"/></td> <td>b</td> <td>a</td> </tr> <tr> <td><input type="checkbox" title="3" οnclick="onCheck(this)"/></td> <td>c</td> <td>a</td> </tr> <tr> <td><input type="checkbox" title="4" οnclick="onCheck(this)"/></td> <td>d</td> <td>a</td> </tr> </table> <input type="button" οnclick="return checkBefore()" value="Delete" /> <mce:script language="javascript"><!-- var arr = [];//存放选中的checkbox的title;title为键值 Array.prototype.contains=function(s){ for(var i=0;i<this.length;i++) { if(this[i]==s) { return i; } } return -1; } function onCheck(o) { var index = arr.contains(o.title); if(o.checked) { if(index==-1) arr.push(o.title); }else { if(index!=-1) arr.splice(index,1); } } function checkBefore() { //alert(arr); if(arr.length==0) { alert("please select !"); return false; } return true; } // --></mce:script>