2024年6月14日发(作者:)
select标签对option元素多选单选以及获取value的
值
```html
```
多选
```html
```
单选
```html
```
获取选中值
```html
var selectElement = mentById("mySelect");
var selectedOption =
s[edIndex].value;
(selectedOption);
```
上述例子中,我们首先通过getElementById(方法获取了id为
"mySelect"的
值,获取了选中的选项,最后使用value属性获取了选项的值。我们可以
将该值输出到控制台上,以便验证正确性。
总结
发布评论