I already have a code that works in disabling enabling elements after clicking a button. However, disabling a checkbox using addClass("disabled")
is not working. How would I do that? Please take a look with my code below. Thanks a lot.
td:nth-child(3)
and td:nth-child(4)
is working fine but td:nth-child(1)
checkbox disable is not working.
$(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");
});
To disable a checkbox use the attribute disabled
. The css class will not have an effect.
$tds1 = $row.find("td:nth-child(1) input[type=checkbox].loan-id-checkbox").attr("disabled", true);
You don't just need to addClass for checkbox you need to set attribute to true for disabling the checkbox like this.
$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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.