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 有时候在页面中有多处checkbox,所以根据id来区别,这时需要根据id来控制全选的区域:


$('#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("请选择删除对象!");
       return;
   }
    if(confirm("您确定要删除选中的项目么?")){
        document.getElementById("delForm").action="/html/com/deleteCallMarketContactAction.do";
        document.getElementById("delForm").submit();
    }
}
posted on 2012-07-09 15:45 canry Tong 阅读(226) 评论(0)  编辑  收藏 所属分类: jsp

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

留言簿

文章分类

文章档案

搜索

  •  

最新评论