Flag entries can have only two states: marked or unchecked. An undefined state is only visual, and it masks the real state of the flag.
, true, false, . "" "" "" onchange.
, , , IE. IE :
document.getElementById("cb1").indeterminate = true;
document.getElementById("cb2").indeterminate = true;
<label for="cb1"><input id="cb1" type="checkbox" checked="checked" />I'm actually checked</label>
<label for="cb2"><input id="cb2" type="checkbox" />I'm actually unchecked</label>
IE . Chrome .
IE , . "" , "" " ", , onchange.
? , IE, , https://github.com/jquery/jquery/issues/1698.
if ( window.navigator.userAgent.indexOf('Trident') >= 0 ) {
$(function(){
$(document).on('mousedown', 'input', function(){
if ( this.indeterminate ) {
$(this).trigger('change');
}
});
});
}
A. Wolff, , , , , :
var checkbox = document.getElementById("cb");
checkbox.indeterminate = true;
$('#cb').one('click', function () {
if (!this.checked) {
this.checked = true;
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
this.dispatchEvent(evt);
}
}).change(function (e) {
console.log(e);
alert(e.originalEvent)
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label for="cb">
<input id="cb" type="checkbox" />click me
</label>