html部分
<input type="checkbox" onclick="ts(this)">js部分
function ts(cb) {
if (cb.readOnly)
cb.checked=cb.readOnly=false;
else if (!cb.checked)
cb.readOnly=cb.indeterminate=true;
}indeterminate属性是独立属性,仅能在js中设置。
本文介绍了一个简单的JavaScript函数,用于控制HTML中的checkbox状态,包括checked、readOnly和indeterminate属性的切换。
html部分
<input type="checkbox" onclick="ts(this)">js部分
function ts(cb) {
if (cb.readOnly)
cb.checked=cb.readOnly=false;
else if (!cb.checked)
cb.readOnly=cb.indeterminate=true;
}

被折叠的 条评论
为什么被折叠?