I'm using jQuery Chosen and I need to put every option text in an array from a multiple select's dropdown.
I can easily get all values in an array with this:
<select id="select_custom" data-placeholder="Choose a city" style="width:50%;" class="chosen-processed" multiple>
<option value="cty01">New York</option>
<option value="cty02">Madrid</option>
<option value="cty03">Montreal</option>
<option value="cty04">Paris</option>
<option value="cty05">Berlin</option>
</select>
var select_custom = jQuery("#select_custom");
select_custom.change(function(){
var values = select_custom.chosen().val();
});
And depending on what option is selected, it will return an array of values like this:
['cty01', 'cty03', 'cty04']
What would be the equivalent of this to get the text instead of the value?
['New York', 'Montreal', 'Paris']
Thanks in advance for your help!
$("#select_custom option[value='cty01']").text()create loop for all value.