Reputation: 11
HTML:
<select id="provider" class="chzn-select" name="provider">
<option value="0">Please Select A Provider</option>
<optgroup label="Canada">
<option value="2043">Bell</option>
<option value="2049">Fido</option>
<option value="2061">Koodo Mobile</option>
<option value="2056">Mobilicity</option>
</optgroup>
</select>
JAVA SCRIPT:
$('#provider').val()
Gives me the value such as "2043" if Bell is selected, how do i get the label text such as "Bell" if Bell is selected.
Upvotes: 1
Views: 120
Reputation: 388316
You can find the selected option using selected-selector and then read its text
$('#provider option:selected').text()
Upvotes: 3