编辑下面的代码:【加编码】
<html> <head> <script> function displayResult(selTag) { var x=selTag.options[selTag.selectedIndex].text; alert("You selected: " + x); } </script> </head> <body> <form> Select your favorite fruit: <select onchange="displayResult(this)"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select> </form> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂