jQuery checkbox values to comma separated list

后端 未结 4 880
南方客
南方客 2021-01-04 03:00

I have several checkboxes with a name array and I want the output of the checked boxes to be a variable with a comma separated list.



        
4条回答
  •  梦谈多话
    2021-01-04 03:42

    jQuery how to get multiple checkbox's value and output as comma separated String list.

    https://www.tutsmake.com/jquery-multiple-checkbox-values-to-comma-separated-string/

        $(document).ready(function() {
            $(".btn_click").click(function(){
     
                var programming = $("input[name='programming']:checked").map(function() {
                    return this.value;
                }).get().join(', ');
     
                alert("My favourite programming languages are: " + programming);
            });
        });
    
    
    
    
    jQuery Get Values of Selected Checboxes
     
    
    
        

    Select your favorite Programming Languages :


提交回复
热议问题