Hi all and thanks for taking the time to answer my question.
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?
selectedOptions returns a HTMLCollection , not an Array .
If you want to get selected option value, you can use $(select element). val() .
Use the jQuery: selected selector in combination with val () method to find the selected option value in a drop-down list.
You can use map
method:
var arr = $('select.skillLevel').map(function(){
return this.value
}).get()
arr
is an array of values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With