ffffff01 ffffff01 - 7 months ago 44
jQuery Question

How to get all option values in a multiple select with jquery?

I'm trying to get all options values of a multiple select with the following code.

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

When I do this I only get [object Object] in return.

Any suggestions on how to solve this?



var arr = [];
$("#SelectRight > option").each(function(){

That will store all values in arr array.

If you want them to be a single string with comma separated, you can go further like this:

var str = arr.join(', ');