dongping1689 2014-06-23 14:03
浏览 24
已采纳

多选复选框选中的问题

What i did

 1. create array of checkboxes with unique numeric ID 
 2. on click of <td>(with unique numeric ID also ) i checked-unchecked the checkbox 
 3. I used jQuery to check-uncheck logic.

Problem : When i click fresh on it will change to checked. Then i again click on it and it unchecked.Then i continue this process and it gets stucks on checked.

http://jsfiddle.net/5zQFe/

  • 写回答

2条回答 默认 最新

  • dongtun1872 2014-06-23 14:28
    关注

    Yup, I just made sure the input was declared rather than the ID of the TD:

    $(document).ready(function () {
        $('.tdbox').click(function () {
            var tdID = $(this).attr('id');
            if ($(this).attr('id') == -1) {
                return false;
            }
            var inp = $(this).find("input[id=" + tdID + "]");
    
            if (inp.is(':checked')) {
                $(inp).prop("checked", false);
                $(this).css('background-color', "");
            } else {
                $(inp).prop("checked", true);
                $(this).css('background-color', "yellow");
            }
        });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 网站出现错误跳转问题
  • ¥15 Docker容器里已经安装了ssh,但打包迁移到新机器一直容器一直提示unrecognized service。
  • ¥15 综合布线实例设计,就好看好看不恐怖可好滤镜好聚
  • ¥15 使用moviepy库视频合并时出错
  • ¥30 FLUENT液固传质UDF
  • ¥15 怎么看梯度直方图以,怎么判断梯度消失/爆炸,怎么解决
  • ¥15 aspnetdll文件访问拒绝
  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403