jqueryselectjquery-selectors

How to get all selected options elements from all select elements in a form?


I have a form with 6 select elements with the class of skillLevel. I need to get (preferably in an array) the values of each select element using jQuery.

How can I do that?


Solution

  • You can use map method:

    var arr = $('select.skillLevel').map(function(){
                  return this.value
              }).get()
    

    arr is an array of values.