Answers for "get options from select js"

1

js extract options from select

// @florinrelea
const selectElementId = 'example'
const htmlOptionsCollections = document.getElementById(selectElementId).options
const options = Array.from(htmlOptionsCollections).map(el=> el.textContent)
console.log(options)
Posted by: Guest on February-06-2021
2

use js to get select value

// reference to 'scripts' select list 
// used throughout the examples below
var sel = document.getElementById('scripts');

// display value property of select list (from selected option)
console.log( sel.value );
Posted by: Guest on February-22-2020

Code answers related to "get options from select js"

Browse Popular Code Answers by Language