How to get all "option" values in "select" by Jquery? How to get all "option" values in "select" by Jquery? jquery jquery

How to get all "option" values in "select" by Jquery?


var values = $("#group_select>option").map(function() { return $(this).val(); });


The following will give you an array of the <option> values

var values = $.map($('#group_select option'), function(e) { return e.value; });// as a comma separated stringvalues.join(',');

Here's a Working Demo. add /edit to the URL to see the code.


This will iterate through all the options and give you their values.Then you can either append them to an array or manipulate them individually.

$('#group_select option').each(function(){    $(this).val()};