How to get all options of a select using jQuery?

Click Upvote picture Click Upvote · Feb 26, 2009 · Viewed 715.9k times · Source

How can I get all the options of a select through jQuery by passing on its ID?

I am only looking to get their values, not the text.

Answer

ybo picture ybo · Feb 26, 2009

Use:

$("#id option").each(function()
{
    // Add $(this).val() to your list
});

.each() | jQuery API Documentation