0

I have 5 inputs checkbox, select 3 and when you want to see the number selected with this function I get the number 3 correctly

$('.pf-fdc-setting .class-users .class-role input:checked').length(); // 3

but if I want to get the 3 values, just send me 1 single value with this function

$('.pf-fdc-setting .class-users .class-role input:checked').val(); // one-value

How can I get the 3 values selected?

Lenin Zapata
  • 1,329
  • 1
  • 9
  • 13

2 Answers2

1

You can use .each() to iterate over the selected items

let values = [];
$('.pf-fdc-setting .class-users .class-role input:checked').each(function() {
  values.push($(this).val());
});
Danny Buonocore
  • 3,568
  • 3
  • 21
  • 44
1

Just Do It:

$('.pf-fdc-setting .class-users .class-role input:checked').each( function( index, element ){
   console.log( $( this ).val() );
});
Imranmadbar
  • 3,491
  • 1
  • 12
  • 25