0

I have multiple form with unique id and has same set of checkbox elements. I want to get the list of checkbox ids in an array using jQuery and send it to mvc action where the argument is of type IEnumberable.

I used the below code in jQuery to get the checked checkbox inside the form but not successful. Can anyone help me how to solve this?

        var test = $("#11form input[type='checkbox']:checked");
        alert(test.length);  

Thanks in advance

4

1 に答える 1

1
var test = $("#11form input[type='checkbox']:checked");

var ids = test.map(function() {
  return this.id;
}).toArray();

デモ

于 2012-08-14T11:26:33.467 に答える