I have a situation where I get the following in JavaScript:
$('<input type="checkbox" name="checkbox1" value="12345">').prop('checked',true);
The above doesn't check the checkbox at all. Also tried:
$('<input type="checkbox" name="checkbox1" value="12345">').attr('checked','checked');
When I do this, I get the value:
$('<input type="checkbox" name="checkbox1" value="12345">').val();
The following is contained in an array:
<input type="checkbox" name="checkbox1" value="12345">
So I usually call above as:
$(data[0]).val();
Why doesn't checking/unchecking using prop or attr work?