Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Selector for select HTML element (for using with onClick as opposed to onChange)
/* assuming we have the following HTML
<select id='s'>
<option selected>Second</option>
var select = document.getElementById('s');
// return the index of the selected option
console.log(select.selectedIndex); // 1
// return the value of the selected option
console.log(select.options[select.selectedIndex].value) // Second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.