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);
}
});