Get Selected <option> Text and Value

Demo



            

You can call the following method to get all the text and value attribute from selected options.

You need to pass the selector of <select> tag to the method getSelectedValuesText and it will return all the selected option's innerHTML and value attribute.

It will return an array of objects containing "text" and "value" keys.

  • text: This is the innerHTML value of selected option.
  • value: This is the value attribute of selected option.