How to get all options of a select using jQuery?

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.
$("#id option").each(function()
{
    // Add $(this).val() to your list
});
example
<select id="members" >
    <option value="">Select</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
</select>
var memberID = '';
$("#members option").each(function()
    {
        if($(this).val() != null && $(this).val() != '') {
            memberID = $(this).val();
        }
    });

Popular posts from this blog

Yii Framework In Update Time View Image In Form

Add a new column to existing table in a migration

Ajax Toggle(on/off) on-click Update