Getting an option text/value with JavaScript

旧巷老猫 提交于 2019-11-27 08:32:54
Chandu

You can use:

var option_user_selection = element.options[ element.selectedIndex ].text
Morganster

In jquery you could try this $("#select_id>option:selected").text()

M99
form.MySelect.options[form.MySelect.selectedIndex].value
var option_user_selection = document.getElementById("maincourse").options[document.getElementById("maincourse").selectedIndex ].text
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!