0

我有以下代码用于选择菜单:

<label for="select-choice-0" class="select">Shipping method:</label>
<select name="select-choice-0" id="select-choice-1">
   <option value="standard">Standard: 7 day</option>
   <option value="rush" >Rush: 3 days</option>
   <option value="express">Express: next day</option>
   <option value="overnight">Overnight</option>
</select>

执行 $('select-choice-1').val() 将为我提供所选选项的值,例如,如果选择了第二个选项,则返回的值将是“rush”。

但是,我想获得字符串“Rush: 3 days”。我怎样才能做到这一点?

谢谢。

4

1 回答 1

0

找到以下作品:

document.getElementById('select-choice-1').options[document.getElementById('select-choice-1').options.selectedIndex].text;
于 2012-05-04T01:20:13.790 回答