Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get select value from select list array in jquery

Tags:

jquery

HTML CODE

<select class="form-control" name="min_select[]">
              <option value="15">15</option>
              <option value="30">30</option>
</select>

JQuery Code

var val1[];
$('select[name="min_select[]"] option:selected').each(function() {
val1.push($(this).val());
});

when i run this code I get empty val array

like image 319
vimal ram Avatar asked Jan 27 '16 04:01

vimal ram


1 Answers

This will also work

var  val1= $("select[name=\'min_select[]\']").map(function() {
    return $(this).val();
}).toArray();
like image 139
johnnitro Avatar answered Oct 13 '22 19:10

johnnitro