Programming Tips - jQuery: get the value of a checkbox

Date: 2016feb3 Library: jQuery Language: javaScript Keywords: checked, ischecked, check Q. jQuery: get the value of a checkbox A. Assuming you have:
<input type=checkbox id=mycheck> My Check
Get the value as a boolean with prop('checked')
const mycheck = $('#mycheck').prop('checked');
That gets you boolean, if you prefer "yes" or "no"
const mycheck = toYesNo($('#=mycheck').prop('checked');
Using this function:
function toYesNo(b) { return b ? 'yes' : 'no'; }
Do NOT use val():
const mycheck = $('#mycheck').val(); // WRONG // Gives you value= from the html no matter if checked or not