js code to get the current select element value_form effects
WBOY
Release: 2016-05-16 18:29:09
Original
1003 people have browsed it
If all option elements under the select element do not specify the selected attribute, the first one will be selected by default.
The index of the selected option element can be obtained through select.selectedIndex.
The selected option element can be obtained through select.options[select.selectedIndex].
option element, the value attribute value of the option element can be obtained through option.value, which is value3; the option element can be obtained through option.text The text inside is text3.
If the option element does not define the value attribute, option.value cannot be obtained in IE, but Safari, Opera, and FireFox can still obtain it through option.value, and the value is the same as option.text.
You can use option.attributes.value && option.attributes.value.specified to determine whether the option element defines the value attribute.
Therefore, the script to obtain the current select element value is as follows:
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