JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="ans" value="1" data-unchecked="0" />
<input type="button" id="button" value="submit" />
<script type="text/javascript">
    $('#button').click(function(){
        alert($('#ans').val())
    });
</script>

JavaScript

$.fn.realVal = function(){
    var $obj = $(this);
    var val = $obj.val();
    var type = $obj.attr('type');
    if (type && type==='checkbox') {
        var un_val = $obj.attr('data-unchecked');
        if (typeof un_val==='undefined') un_val = '';
        return $obj.prop('checked') ? val : un_val;
    } else {
        return val;
    }
};