[英]How to disable checkbox in a specific table row after clicking a button using javascript?
我已经有一个代码,可以在单击按钮后禁用启用元素。 但是,使用addClass("disabled")
禁用复选框不起作用。 我该怎么做? 请看下面我的代码。 非常感谢。
td:nth-child(3)
和td:nth-child(4)
正常工作,但td:nth-child(1)
复选框禁用不起作用。
$(document).on('click', '.generate', function(e){
e.preventDefault();
var $row = $(this).closest("tr"),
$tds1 = $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled");
$tds3 = $row.find("td:nth-child(3) a.generate").addClass("disabled");
$tds4 = $row.find("td:nth-child(4) a.btn-showAmort").removeClass("disabled");
});
要禁用复选框,请使用属性disabled
。 css类将无效。
$tds1 = $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").attr("disabled", true);
您不仅需要为复选框添加addClass,还需要将attribute设置为true来禁用这样的复选框。
$row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled", true);
OR
$row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").addClass("disabled",false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.