How can I elegantize this verbose jquery?
问题 I need to get the value of the checked checkbox (only one is allowed to be checked at a time), and I have this verbose code to do so: if (!checkboxSelected) { return; } if($("#ckbx_produceusage").is(':checked')) { rptval = $('#ckbx_produceusage').val(); } else if($("#ckbx_deliveryperformance").is(':checked')) { rptval = $('#ckbx_deliveryperformance').val(); } else if($("#ckbx_fillrate").is(':checked')) { rptval = $('#ckbx_fillrate').val(); } else if($("#ckbx_pricecompliance").is(':checked'))