:: 首页 :: 新随笔 ::  :: 聚合  :: 管理

对checkbox的操作

Posted on 2012-10-29 09:02 谁用我名字啦? 阅读(200) 评论(0)  编辑  收藏 所属分类: JQuery
反选
$("#btn4").click(function(){
        $("[name='checkbox']").each(function(){
            if($(this).attr("checked"))
            {
                $(this).removeAttr("checked");
        
            }
            else
            {
                $(this).attr("checked",'true');
            }
        });
    });

全选
$("#btn1").click(function(){
        alert('');
        $("[name='checkbox']").attr("checked",'true');//全选
    });

选中所有奇数
$("#btn3").click(function(){
        alert('');
        $("[name='checkbox']:even").attr("checked",'true');//选中所有奇数
    });

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


网站导航: