Get multiple select value

Description

The following code shows how to get multiple selected value.

Example


<html>
<head>
<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--   ww  w.j  a  v a 2s  . c  o m-->
    function displayVals() {
      var singleValues = $("#single").val();
      $("p").html(singleValues.join(","));
    }
    $("select").change(displayVals);
  });
</script>
</head>
<body>
  <p></p>
  <select id="single" multiple="multiple">
    <option>Single</option>
    <option>Single2</option>
    <option>Single3</option>
  </select>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities