我有一個正常的下拉,我想獲得當前選定的索引,並把它放在一個變量。 Jquery或JavaScript。 jquery轉載。如何獲得一個下拉選定的索引
<select name="CCards">
<option value="0">Select Saved Payment Method:</option>
<option value="1846">test xxxx1234</option>
<option value="1962">test2 xxxx3456</option>
</select>
調用'index()'比單純使用標準DOM'selectedIndex'更加可讀的繁忙工作列表搜索繁忙工作。我會堅持使用純DOM屬性。 – bobince 2010-09-02 15:00:15
@bobince:我也不會用jQuery來解決這個問題,但是因爲OP要求提供jQuery解決方案...... :-) – naivists 2010-09-02 15:02:49
這是最簡單的,正是我所期待的。第二行工作完美,我用它像var indx = $(「select [name ='CCards'] option:selected」)。index(); – user357034 2010-09-02 15:02:59