I have created a dom selector that essentially has all of the checkboxes as a node array in part of my app:
var checkboxes = document.getElementById("factors").querySelectorAll('input[type=checkbox]');
This returns a node array for 10 checkboxes with each of the node items looking like this:
>checkbox[0]
><input name="chkVal0" type="checkbox" role="checkbox" aria-checked="true" class="dijitReset dijitCheckBoxInput" data-dojo-attach-point="focusNode" data-dojo-attach-event="ondijitclick:_onClick" value="on" tabindex="0" id="dijit_form_CheckBox_0" checked="checked" style="user-select: none;">
I want to have a function that unchecks all of the checkboxes at once, but I can't seem to achieve this using the dom selector. I've tried a few things on a single item first, but it doesn't seem to uncheck the box:
var checkbox_one = checkboxes[0];
//Using jquery and props
$(checkbox_one).prop("checked", "unchecked") //Nothing
//2nd try
$(checkbox_one).prop("checked", false) //Nothing
//3rd try using attr
$(checkbox_one).attr("checked", "uncheck"); //Nothing
$(checkbox_one).attr("checked", false); //Nothing
I've tried a few similar things using aria-checked = false
and value=off
but nothing seems to work. Any suggestions on how to overcome this issue and get the boxes to uncheck using the dom selector?