I am trying to toggle a checkbox between checked and un-checked using the following code, but it seems to only un-check.
var checkbox = $this.find('[name="category"]');
if ('checkbox:checked') {
checkbox.prop("checked", false);
} else {
checkbox.prop("checked", true);
}
How can I make it toggle correctly?
Is there a better way to do this instead of doing if/else statements? .toggle() doesn't seem to work for checkboxes correct?