Skip to content

Instantly share code, notes, and snippets.

@AllenSH12
Created July 3, 2018 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllenSH12/1dad20846eca2dd037b79e9561fe5e4d to your computer and use it in GitHub Desktop.
Save AllenSH12/1dad20846eca2dd037b79e9561fe5e4d to your computer and use it in GitHub Desktop.
option element value
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<select name="foobar" id="testSelect">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<script>
document.getElementById('testSelect').onchange = function(e) {
console.log(e.target.value);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment