記錄dom的學(xué)習(xí)經(jīng)驗(yàn)。下次忘記的時(shí)候直接來拿
<select id="typevalue" onChange="modifyType();">
<option value="1" id="0">11</option>
<option value="2" id="1">22</option>
<option value="3" id="2">33</option>
<option value="4" id="3">44</option>
<option value="5" id="4">55</option>
<option value="6" id="5">66</option>
<option value="7" id="10">77</option>
</select>
獲取選中的option的text值
var typevalue = document.getElementById("typevalue");
var typevalueText = typevalue.options[typevalue.selectedIndex].text;
獲取選中的option的ID值
var typevalue = document.getElementById("typevalue");
var typevalueId = typevalue.options[typevalue.selectedIndex].id;
<select id="typevalue" onChange="modifyType();">
<option value="1" id="0">11</option>
<option value="2" id="1">22</option>
<option value="3" id="2">33</option>
<option value="4" id="3">44</option>
<option value="5" id="4">55</option>
<option value="6" id="5">66</option>
<option value="7" id="10">77</option>
</select>
獲取選中的option的text值
var typevalue = document.getElementById("typevalue");
var typevalueText = typevalue.options[typevalue.selectedIndex].text;
獲取選中的option的ID值
var typevalue = document.getElementById("typevalue");
var typevalueId = typevalue.options[typevalue.selectedIndex].id;