1: Get the select object: var myselect =document.getElementById("test");
2: Get the index of the selected item: var index=myselect.selectedIndex; // selectedIndex represents the index of the selected item
3: Get the value of the selected options: myselect.options[index].value;
4: Get the text of the selected options: myselect.options[index].text;
Two: jquery method (provided that the jquery library has been loaded)
1:var options=$("#test option:selected"); //Get the selected item
2:alert(options.val()); //Get the value of the selected item
3:alert(options.text()); //Get the text of the selected item
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn