79167254

Date: 2024-11-07 16:13:06
Score: 0.5
Natty:
Report link

One line to get an array of selected texts or values

var array_of_texts = $('#Your_multiple_select option:selected').toArray().map(item => item.text);

Output: ["text1", "text2"]

var array_of_values = $('#SelectQButton option:selected').toArray().map(item => item.value);

Output: ["value1", "value2"]

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: lisandro