获取选择菜单中所选项目的字符串值

时间:2012-04-29 09:48:10

标签: jquery-mobile

我有一个选择菜单的代码:

<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天”。我怎么能这样做?

感谢。

1 个答案:

答案 0 :(得分:0)

找到以下作品:

document.getElementById('select-choice-1').options[document.getElementById('select-choice-1').options.selectedIndex].text;
相关问题