jquery checked 操作多选

来源:互联网 发布:剑三丐姐脸型数据 编辑:程序博客网 时间:2024/06/05 19:49
  1. $( function() {     
  2.     
  3.     //全选     
  4.     $("#selectAll").click( function() {     
  5.         $("input[name='send-mail']").each( function() {     
  6.             $(this).attr("checked"true);     
  7.         });     
  8.     });     
  9.     // 反选     
  10.     $("#inverseAll").click( function() {     
  11.         $('input[name="send-mail"]').each( function() {     
  12.             $(this).attr("checked", !$(this).attr("checked"));     
  13.         });     
  14.     });     
  15.     
  16.     // 取消全部     
  17.     $("#deselectAll").click( function() {     
  18.         $("input[name='send-mail']").each( function() {     
  19.             $(this).attr("checked"false);     
  20.         });     
  21.     });     
  22.     
  23.     // 选中的值     
  24.     $("#sendMailAll").click( function() {     
  25.         var selectedStr = "";     
  26.         var $sendMail = $("input[name='send-mail']");     
  27.         $sendMail.each( function() {     
  28.             if ($(this).attr("checked")) {     
  29.                 selectedStr += $(this).val() + ",";     
  30.             }     
  31.         });     
  32.         if ($.trim(selectedStr) == "") {     
  33.             alert("请未选中任何数据!");     
  34.             return false;     
  35.         }     
  36.                alert(selectedStr );     
  37.              
  38.     });     
  39.     
  40. });  
0 0