从SELECT中的多个选择中获取值 [英] Get values from multiple selections in SELECT
本文介绍了从SELECT中的多个选择中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个选择框,您可以选择多个选项.我需要使用JavaScript访问所有选定的值-可能是一个值数组?
I have a selection box that allows you to select multiple options. I need to access all the selected values with JavaScript - possible a array of values?
推荐答案
这是取回所选值数组的最佳方法:
This is the best way to get an array of the selected values back:
$("#mySelect").val(); // Return an array of the selected options values
这假定multiple="mutliple"
和size
在select
元素上大于1.
This assumes that multiple="mutliple"
and size
is greater than one on the select
element.
这篇关于从SELECT中的多个选择中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文