jquery multiple checkboxes array

前端 未结 6 1396
孤独总比滥情好
孤独总比滥情好 2020-12-04 19:45




        
6条回答
  •  孤街浪徒
    2020-12-04 20:24

    A global function that can be reused:

    function getCheckedGroupBoxes(groupName) {
    
        var checkedAry= [];
        $.each($("input[name='" + groupName + "']:checked"), function () {
            checkedAry.push($(this).attr("id"));
        });
    
         return checkedAry;
    
    }
    

    where the groupName is the name of the group of the checkboxes, in you example :'options[]'

提交回复
热议问题