For the checkbox, i've put a function that will add on the checked property dynamically as below
if ($(_this).prop("checked") == true) {
$(_this).attr('checked', 'checked');
}
else if ($(_this).prop("checked") == false) {
$(_this).removeAttr('checked');
}
when it shows the below as the property for the checkbox
<center><input onclick=\"CheckboxIsChecked(this)\" type=\"checkbox\" checked=\"checked\"></center>
but when a function catch whether there is the checked property in the element as below. it would always return a false. What is wrong with my code?
$(List[i].Checkbox).prop("checked") ? true : false
ParameterData[i].Maintain_flag
? Is it a string, or is it a DOM object (and if so, how does it get its value)? Other than that,.prop("checked")
already returns true or false, so you can remove the?:
operator.console.log($(List[i].Checkbox)[0].tagName); console.log($(List[i].Checkbox)[0].type)
and share the result with us. It should printINPUT
and thencheckbox
. If it doesn't, then your objects do not contain what you say they contain. It will also help if you show us the code that sets all theList[i].Checkbox
values.console.log($(List[i].Checkbox)[0].tagName);
it outputcenter
whileconsole.log($(List[i].Checkbox)[0].type)
output anundefined
its innerHTML is<input onclick=\"CheckboxIsChecked(this)\" type=\"checkbox\" checked=\"checked\">