[jQuery] how do you toggle a checkbox value?
I know there is a quirk with checkboxes, but I am under the impression
that setting the check state to boolean values within javascript takes
care of that. Unfortunately, this assumption is proving to be an
incorrect one.
// Here is a snippet of code
$("li#" + liId).click(function(event){
var checkbox = $("#" + checkboxId) // this is being found as
expected
// flip the checkbox state
console.log(checkbox.checked)
checkbox.checked = !checkbox.checked
====== End
// This code snippet always returns Undefined even when the checkbox
is checked
console.log(checkbox.checked)
// which then makes the flip of the values not work
checkbox.checked = !checkbox.checked
What is the proper way to reference the checked value and flip the
value?
Thanks.