I tried many ways to get the selected state of a checkbox. Its a input field with type checkbox.
I tried the following methods to get the state, but all returns false
. Only if the checkbox was set selected/not selected with jQuery before (this was done with $.prop("checked", "true")
.
$("#ID").prop("checked");
$("#ID").val(); //returns "on" everytime
$("#ID").attr("checked");
$("#ID").checked; //undefined
ID is a real id in my Code!
The selected state is also set with jQuery like this:
$(columns[i]).children().first().prop("checked", stateArray[i]);
The checkboxes are in a KendoGrid and columns.children gets all td
's and first()
returns the input.
stateArray
is an array with true/false.
Nothing works... Do you got an idea?
Regards
EDIT: I found the fault... the ID generated for the inputs was always the same... so it selected the first element which was not selected... I'm sorry for that!