var select = document.getElementById("selectID");
var optionValue = select.options[select.selectedIndex].value;
var optionText = select.options[select.selectedIndex].text;
本文详细介绍了如何使用JavaScript获取HTML元素的值和文本,包括通过getElementById方法定位特定元素,然后通过options属性和selectedIndex属性获取选项的值和文本。
var select = document.getElementById("selectID");
var optionValue = select.options[select.selectedIndex].value;
var optionText = select.options[select.selectedIndex].text;
1414
3554

被折叠的 条评论
为什么被折叠?