您好我正在尝试聚合从不同的多个选择中获取的选项,但它只从其中一个中选择。我最终会有15个不同的(它们都隐藏在另一个下拉列表中)。 http://jsfiddle.net/wZauw/1/
<p></p>
<div id="accounting" class="selector subcontent">
<select id="trade_select_accounting" multiple class="selector wrap-left">
<option>Auditing</option>
<option>Bookkeeping</option>
</select>
</div>
<div id="administration" class="selector subcontent">
<select id="trade_select_administration" multiple class="selector wrap-left">
<option>Clerical</option>
<option>Personnel</option>
<option>Training</option>
</select>
</div>
<script>
function displayVals() {
var multipleValues = $('[id^=trade_select_]').val() || [];
$("p").html(" <b>Selected Trades:</b> " +
multipleValues.join(", "));
}
$("select").change(displayVals);
displayVals();
</script>