我有一个复选框,我想禁用复选框的禁用文本,但我没有这样做。我有以下代码:使复选框和复选框文本禁用
$('input:checkbox[type="checkbox"]').each(function() {
$(this).attr("disabled", true).attr("readonly", true);
});
上面的代码是不是让我的复选框被禁用,而我能够检查并取消选中该复选框。
我唯一想做的事情是使复选框被禁用,如果我从后端加载的复选框的值被选中,那么它不应该影响它的状态。我也想禁用复选框的文本。
请注意我已经生成动态的复选框,这里是它的代码:
if (cellvalue == "True") {
html = "<input type='checkbox' class='checkboxUser' id='checkbox" + rowid + "' checked/>"
}
else {
html = "<input type='checkbox' class='checkboxUser' id='checkbox" + rowid + "'/>"
}
return html;
分享你的HTML样本 –
你不需要':checkbox'和'[类型= “复选框”]'在一起。其中之一就足够了。 – techfoobar
@ArunPJohny你可以让我知道你想要哪个输入文本html,并且我正在动态生成复选框... – HarshSharma