html部分
<input type="checkbox" οnclick="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中设置。
html部分
<input type="checkbox" οnclick="ts(this)">
js部分
function ts(cb) {
if (cb.readOnly)
cb.checked=cb.readOnly=false;
else if (!cb.checked)
cb.readOnly=cb.indeterminate=true;
}