3-Way Checkbox

by Peter Kaagman

HTML

<p>3-way checkbox</p>
<input type="checkbox" class="chk" id="chk_1" >
<div id="out"></div>

JavaScript

$(".chk").prop("indeterminate", true);
$("#out").append("Checked "       + $('#chk_1').prop('checked') + "<br>");
$("#out").append("Indeterminate " + $('#chk_1').prop('indeterminate') );

$(".chk").click(function(event){
  event.preventDefault();
  
  $("#out").empty();
  console.log(this);
  $("#out").append("Checked "       + this.checked + "<br>");
  $("#out").append("Indeterminate " + this.indeterminate );
});

//$(".chk").on(change,function(event){
//  event.preventDefault();
//})