posts - 0,  comments - 19,  trackbacks - 0
          1 js中:

          $("#allCheck").change(function(){
                  var flag = $(this).attr("checked");
                  $('#delForm input[type="checkbox"]').each(function () {
                      $(this).attr('checked',flag)})
              });

          2 jsp中:

          <th scope="col" class="borl_no"><input id="allCheck" type="checkbox" name="" value="" /></th>

          3 有時(shí)候在頁(yè)面中有多處checkbox,所以根據(jù)id來(lái)區(qū)別,這時(shí)需要根據(jù)id來(lái)控制全選的區(qū)域:


          $('#checkid').click(function(){
            var list = $('[id=check]').length;
            if($('#checkid').attr("checked")==true){
             for(var i = 0 ; i < list ; i ++){
              $('[id=check]').attr("checked","true");
             }
            }else if($('#checkid').attr("checked")==false){
             $('[id=check]').click();
            }
           });
          等同于
          $("#checkid").change(function(){
                  var flag = $(this).attr("checked");
                  $('[id=check]').each(function () {
                              $(this).attr('checked',flag)})
              });

          4 是否選擇checkbox判斷:

          function del(){
              var num=0;
              $('input[type="checkbox"]').each(function () {
                  if ($(this).attr('checked')) {
                      num++;
                  }
              });
             if(num==0){
                 alert("請(qǐng)選擇刪除對(duì)象!");
                 return;
             }
              if(confirm("您確定要?jiǎng)h除選中的項(xiàng)目么?")){
                  document.getElementById("delForm").action="/html/com/deleteCallMarketContactAction.do";
                  document.getElementById("delForm").submit();
              }
          }
          posted on 2012-07-09 15:45 canry Tong 閱讀(241) 評(píng)論(0)  編輯  收藏 所屬分類: jsp
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          留言簿

          文章分類

          文章檔案

          搜索

          •  

          最新評(píng)論

          主站蜘蛛池模板: 伊吾县| 顺昌县| 宁晋县| 资兴市| 楚雄市| 正镶白旗| 石景山区| 望江县| 花莲县| 莲花县| 浦县| 遵义市| 合阳县| 安宁市| 伊宁市| 康马县| 合江县| 华宁县| 郧西县| 闸北区| 喀什市| 乳山市| 金寨县| 岚皋县| 麻城市| 盖州市| 文山县| 上饶县| 会东县| 军事| 长顺县| 土默特左旗| 务川| 莱阳市| 上思县| 临高县| 吴旗县| 集安市| 石狮市| 泰宁县| 西乌珠穆沁旗|