$(function(){ monicheckbox(); $(".phone_btn").click(function(){ $(".biaodan").show(); }) }) function banform(){ $(".label-checkbox").each(function () { if ($(this).find("input").prop("checked")) { var val = $(this).find("input").attr("data-val"); if($(this).parents(".xuanze").find("input.get").val()){ $(this).parents(".xuanze").find("input.get").val($(this).parents(".xuanze").find("input.get").val()+","+val); }else{ $(this).parents(".xuanze").find("input.get").val(val); } } }); } function monicheckbox(){ $(document).on("change", ".label-checkbox input", function () { if ($(this).prop("checked")) { $(this).parent().addClass("on") } else { $(this).parent().removeClass("on") } $(this).parents(".xuanze").find("input.get").val(""); banform(); }); $(".label-checkbox").each(function () { if ($(this).find("input").prop("checked")) { $(this).addClass("on") } }); }