- JS代码
- //全选
- function upCheckAll(){
- if($("#upcheckboxall").attr("checked") == true) {
- $("input[name='upcheckbox']").each(
- function() {
- if ( ! $(this).attr("disabled")){
- $(this).attr("checked", true);
- }
- }
- );
- }else{
- $("input[name='upcheckbox']").each(
- function() {
- if ( ! $(this).attr("disabled")){
- $(this).attr("checked", false);
- }
- }
- );
- }
- };
- //取消全选
- function downCancelCheckAll(){
- if($("#upcheckboxall").attr("checked") == true){
- $("#upcheckboxall").attr("checked", false);
- }
- }
XML/HTML代码
- <table border="0" cellspacing="10" cellpadding="0" style="margin-left:200px;">
- <tr>
- <td><input type="checkbox" id="upcheckboxall" onclick="upCheckAll()" />td>
- <td>全选td>
- tr>
- <tr>
- <td><input name="upcheckbox" type="checkbox" onclick="downCancelCheckAll()" />td>
- <td>记录1td>
- tr>
- <tr>
- <td><input name="upcheckbox" type="checkbox" onclick="downCancelCheckAll()" />td>
- <td>记录2td>
- tr>
- table>