解决方案 »

  1.   


    $('#tblPro').on('click', '.checkbox', function(){
        if(){
            // code
        }
    });
      

  2.   

    楼主要实现单选,为什么不用radio呢,如下让循环生成的radio   name保持一致,这样应该就用不上之后的checkbox操作代码了s += "<td><input  type='check"+sp.OrderId+"' name='check' type='radio'/></td>";
      

  3.   


    $(".checkbox").live('click',function(){
    if($(this).attr("checked"))
    ......
    });
      

  4.   

    之前考虑过了  但是 全选 是为了删除   O了,那可以这样,帮点击事件时,每次先把checkbox全部uncheck状态,再将当前点击的checkbox通过$(this).attr("checked",true)
      

  5.   

    之前考虑过了  但是 全选 是为了删除   
    等等,你这还得支持全选删除,那得额外加个button控制全选或全不选了吧还有点击事件可以单独写一个function
    然后在动态生成checkbox时绑上,如
    function getOne(){
    ///加单选控制操作
    }
    s += "<td><input  type='check"+sp.OrderId+"' name='check' type='radio'  onclick='getOne();'/></td>";
    这样就不用担心原因 大概是  在表格里面的checkbox生成完毕之前  这个代码就运行了  
      

  6.   

    你的live方法会实时监控,后续的checkbox也会增加上事件,live的事件中不要再给checkbox增加click事件了,要不没点击一次就会增加一次click事件一直累加起来<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(':checkbox').live('click', function () {
            if (this.checked) $(this).siblings().attr('checked', false);
        });    setTimeout(function () {
            $(document.body).append('<input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/>');
        }, 3000);
    </script> 
      

  7.   

    贴出你的代码!帮你测试一下
    不要截图,我们不是 OCR
      

  8.   

                $.each(res, function(index, sp) {                s += "<tr class='s1' id=" + sp.OrderId + ">";
                    s += "<td> <input id='check" + sp.OrderId + "' name='check" + sp.OrderId + "' type='checkbox'/> </td>";
                    s += "<td >" + sp.OrderNo + "</td>";
                    s += "<td >" + sp.CustomerName + "</td>";
                    s += "<td >" + sp.OutDate + "</td>";
                    s += "<td>" + sp.SalesName + "</td>";
                    s += "<td>" + sp.Delivery + "</td>";
                    s += "<td>" + sp.Res + "</td>";
                    s += "</tr>"            });            $("#tblPro").append(s);            $(":checkbox").live("click", function() {                //                           $(":checkbox").click(function() {
                    alert(this.checked);
                    if (this.checked){
                        $(this).siblings().attr("checked", false);
                        $(this).attr("checked", true);
                    }
                    //                           });
                    //            if (this.checked) 
                    //            $(this).siblings().attr('checked', false);            });现在  这样我能找到当前点击的checkbox  alert会弹出true  但是  $(this).siblings().attr("checked", false);
                        $(this).attr("checked", true);这两句代码没有效果  依然不能实现单选
      

  9.   

    改变状态用prop$(this).prop("checked", true);获取有没选中$(this).prop("checked");选中为true,没选中为false