這會獲取我的下拉菜單中所選內容的值。從下拉框中獲取文本
document.getElementById('newSkill').value
但是,我不能找出下拉菜單中當前顯示的文本的屬性。我試過「文字」,然後看着W3Schools,但沒有答案,這裏有人知道嗎?
對於那些不確定的,這裏是一個下拉框的HTML。
<select name="newSkill" id="newSkill">
<option value="1">A skill</option>
<option value="2">Another skill</option>
<option value="3">Yet another skill</option>
</select>
對於那些遲到的人來說,有幾個建議,但沒有人注意到他們說.value他們應該說什麼.text,這是一個令人困惑的日子,對我們來說都是如此。 – Teifion 2008-09-19 10:59:14