是否可以禁止对复选框执行某些操作?例如,我想让 $('#post-id') 和 $('#activation') 复选框始终处于选中状态,而无法取消选中它们?
$("#activation").attr("checked", true);
$("#post-id").attr("checked", true);
您可以在这里找到我的示例: https://jsfiddle.net/9LzLm9hx/1/
最佳答案
你可以这样使用
$( '#common' ).on('click', function () {
$( '.common-inputs [type="checkbox"]:not([disabled])' ).prop('checked', this.checked);
});
//checkbox
$("#activation").attr("checked", true);
$("#post-id").attr("checked", true);
$("#activation").attr("disabled", true);
$("#post-id").attr("disabled", true);
关于javascript - 如何禁止取消选中复选框元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34039732/