273681-1.html (607B)
1 <!DOCTYPE html> 2 <html> 3 <body> 4 <form> 5 <select size=2 id="test"> 6 <option>A</option> 7 <option>B</option> 8 <option>C</option> 9 <option>D</option> 10 <option>E</option> 11 <option>F</option> 12 <option>G</option> 13 <option>H</option> 14 <option selected>I</option> 15 <option>J</option> 16 <option>K</option> 17 <option>L</option> 18 <option>M</option> 19 <option>N</option> 20 </select> 21 <script> 22 // flush layout 23 document.body.offsetWidth 24 25 // Now change the text of the currently selected option 26 var obj = document.getElementById("test"); 27 var pos = obj.selectedIndex; 28 obj.options[pos].text = "tag"; 29 </script> 30 </form> 31 </body> 32 </html>