Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如果复选框不是';不要检查,做点什么_Jquery - Fatal编程技术网

Jquery 如果复选框不是';不要检查,做点什么

Jquery 如果复选框不是';不要检查,做点什么,jquery,Jquery,弄清楚这个有点困难。如果第二个和第三个td中的复选框均未选中,则禁用第四个中的复选框 $('#allergies tbody tr').each(function () { if ($('td:eq(1) input[type="checkbox"]:not(:checked)', $(this)).length > 0 && $('td:eq(2) input[type="checkbox"]:not(:checked)', $(this)).lengt

弄清楚这个有点困难。如果第二个和第三个
td
中的复选框均未选中,则禁用第四个中的复选框

$('#allergies tbody tr').each(function () {
  if ($('td:eq(1) input[type="checkbox"]:not(:checked)', $(this)).length > 0 
      && $('td:eq(2) input[type="checkbox"]:not(:checked)', $(this)).length > 0) {
      $("td:eq(3) input", $(this)).attr('disabled', false);
  }
});
到tr使用中的特定值

$('#allergies tbody tr').each(function () {
  if ($('td:eq(1) input[type="checkbox"]:not(:checked)', $(this)).length > 0 
      && $('td:eq(2) input[type="checkbox"]:not(:checked)', $(this)).length > 0) {
      $("td:eq(3) input", $(this)).prop('disabled', true);
  }
});

你的逻辑是正确的,但可读性较差。。 把它们分成小块

$('#allergies tbody tr').each(function () {
    var $this  = $(this);
    var chk1 = $this.find('td:eq(1) input[type="checkbox"]').is(':checked');
    var chk2 = $this.find('td:eq(2) input[type="checkbox"]').is(':checked');

    // If both are false then disable else 
    // enable them
    if(chk1 === false && chk2 === false){
       $this.find('td:eq(3) input').prop('disabled', true);
    }
    else{
       $this.find('td:eq(3) input').prop('disabled', false);
    }
});

是的,我是个弱智,用假来表示残疾,而不是真的。
$('#allergies tbody tr').each(function () {
    var $this  = $(this);
    var chk1 = $this.find('td:eq(1) input[type="checkbox"]').is(':checked');
    var chk2 = $this.find('td:eq(2) input[type="checkbox"]').is(':checked');

    // If both are false then disable else 
    // enable them
    if(chk1 === false && chk2 === false){
       $this.find('td:eq(3) input').prop('disabled', true);
    }
    else{
       $this.find('td:eq(3) input').prop('disabled', false);
    }
});