有一个gridview··每一行前面有一个checkbox···选中了几个,要遍历没有选中的那几个checkbox···到达一定条件的,让checkbox变为不可选。

解决方案 »

  1.   


    $(".checkbox的类名 :checkbox").each(function() {
                        if ($(this).is(":checked") && $(this).attr("disabled") == false) {
        //被选中的
    }
      

  2.   

    $(":checkbox[checked!=checked]").each(function()//所以未选中的
    {
      alert($(this).val());
    });
      

  3.   


    $("#gvid :not(:checked)").each(function(i){//未选中的
                alert($(this).attr("id"));
            });
      

  4.   

        $(function () {
            var max = 3, cbs = $('#gridview :checkbox');//gridview改为你的GridView的ID
            cbs.click(function () {
                if (cbs.filter(':checked').size() >= max) cbs.filter(':not(:checked)').attr('disabled', true);
                else cbs.filter(':disabled').attr('disabled', false);
            });
        });
      

  5.   

    HTML:
    <div id="gridview">
        <input type="checkbox" checked="checked" value="1"/>
        <input type="checkbox" checked="checked" value="1"/>
        <input type="checkbox" checked="checked" value="1"/>
        <input type="checkbox" value="1"/>
        <input type="checkbox" value="2"/>
        <input type="checkbox" value="3"/>
    </div>
    js:
    $(function(){
                $('#gridview :checkbox:not(:checked)').attr("disabled",function (){return $(this).val()!=1 && $(this).val()!=2;});
            });