Note: I'm using jQuery to access the DOM element but plain JavaScript to assign the event to it, so I doubt jQuery has anything to do with it
Check this jsFiddle.
$(document).ready(function() {
$('input')[0].indeterminate = true;
$('input')[0].addEventListener("click", function(event) {
console.log(event.target.checked)
alert("Check is: " + event.target.checked);
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" checked>
If you open it on Chrome and click on the checkbox, the alert message says "Check is: false" whereas if you open it on Microsoft Edge and click on the checkbox, the message says "Check is: true", meaning that the state of the check property changes with the browser.
I tried setting the checked property along with the indeterminate property to see if I enforced that it would treat it the same way, but the results are the same
$(document).ready(function() {
$('input')[0].indeterminate = true;
$('input')[0].checked = false;
$('input')[0].addEventListener("click", function(event) {
console.log(event.target.checked)
alert("Check is: " + event.target.checked);
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" checked>
Is this a bug on Edge or Chrome or is there a way to have a congruent behavior across all browsers?