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,417
  • 1
  • 11
  • 14

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,731
  • 3
  • 24
  • 46
1

Just Do It:

$('.pf-fdc-setting .class-users .class-role input:checked').each( function( index, element ){
   console.log( $( this ).val() );
});
Imranmadbar
  • 4,681
  • 3
  • 17
  • 30