jq查找和拼接checkbox的值

var product_name = '';
        $("input[name='product']:checkbox").each(function () {
            if ($(this).is(":checked")) {
                product_name += $(this).attr('value') + ',';
            }
        });
        product_name = product_name.substring(0,product_name.length-1)
        if(product_name != ''){
            $(".products").val(product_name);
        }

猜你喜欢

转载自www.cnblogs.com/pangchunyu/p/12424744.html