Does anyone know how to get the selected values from a select box that has multiple set.
thanks
<html>
<head>
<script type="text/javascript">
function getS开发者_如何学CelectedValues()
{
  $("#selectID").?????
}
</script>
</head>
<body>
<select id="selectID" MULTIPLE>
  <option>Volvo</option>
  <option>Saab</option>
  <option>Mercedes</option>
  <option>Audi</option>
</select>
<a href="javascript:getSelectedValues()>press</a>
</body>
</html>
$("#selectID").val();
From the jQuery API documentation on the val() method:
The .val() method is primarily used to get the values of form elements. In the case of <select multiple="multiple"> elements, the .val() method returns an array containing each selected option.
You want to use the selected selector
http://api.jquery.com/selected-selector/
$("#selectID option:selected").each(function () {
            $(this).val(); //this is one of the selected values
          });
$("#selectID").val() returns a comma delimited list of selected values.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论