$("#theKeyAttr").find(":checkbox").each(function () { if($(this).is(':checked')){ theChecked += ',' +$(this).val(); } });