JSFiddle - React, Tailwind, and code Playground
HTML
请打开 console 以后再 选择, 按住 Ctrl 或 Shift 多选。<br/>
<select id="select" multiple name="select">
<option value="value1">Value 1</option>
<option value="value2" selected>Value 2</option>
<option value="value3">Value 3</option>
</select>
<div style="height:50px;"/>
JavaScript
var selectElem = document.getElementById('select');
selectElem.addEventListener('change', onSelect_change);
function onSelect_change(e){
// get the selected value :
var selectedValue = e.target[e.target.selectedIndex].value;
// you can also do it using domEvent.target.value but the other solution allows you to get every option's property you want
console.log("Selected: " + selectedValue);
const options = e.target.options;
console.log("options: " + options);
console.log(options);
const area = Object.keys(options)
.filter(i => options[i].selected === true)
.map(i => options[i].value);
console.info("area:"+area);
}