Reputation: 17321
how to i can get all checked input values to array?
i can get all checked inputs but cant to get values.
jQuery:
$("[id^='generate_']").click(function() {
val=$(this).closest('tr').find("#cnt").text();
var obj = $("#testSlide_"+val).find(':checkbox');
var childCount = obj.size();
var checkedCount = obj.filter(':checked').length;
var checkValues = [];
$(childCount).each(function() {
alert($(this).val());
checkValues.push($(this)val());
});
});
i want to use ajax and send to serverside and use foreach .
Upvotes: 1
Views: 105
Reputation: 165971
You can use .map()
to return a new jQuery object containing the return values of a function:
var values = $("#testSlide_"+val).find(':checkbox:checked').map(function () {
return this.value;
}).get();
The call to .get()
is there to convert the jQuery object into a native array.
Upvotes: 2