Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE HTML> <html> <head> <title>Title of the Document</title> </head> <body> <select id="select" multiple> <option value="green" selected>Green</option> <option value="red" selected>Red</option> <option value="blue">Blue</option> </select> <script> // get all selected values from multiple selection let selected = Array.from(select.options).filter(option => option.selected).map(option => option.value); alert(selected); // green, red </script> </body> </html>