问题描述:

I need to get a array/list of all the select dropdowns in a HTML page. Any idea how I can achieve this using jQuery?

Thanks.

网友答案:

Like this:

var $select_array = $('select');
网友答案:

This will do the magic:

var allSelects = $('select');
网友答案:

You can use something similar to this.

var dropdowns = [];

    $('option').each(function(){
       dropdown.push($(this))
    });
网友答案:

If you want to retrieve all of the selections made by various drop down lists on a page you would do it like:

var selections = []

jQuery('select').each(function(){
    selections.push(jQuery(this).val());
});

See my working example

相关阅读:
Top