Skip to content

Instantly share code, notes, and snippets.

@EricDavies
Created August 24, 2015 22:20
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 EricDavies/c2c9fbfc61a659ea1e53 to your computer and use it in GitHub Desktop.
Save EricDavies/c2c9fbfc61a659ea1e53 to your computer and use it in GitHub Desktop.
adding a label to a select option.
<!DOCTYPE html>
<html>
<body>
<select id="xx">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<script>
var x = document.createElement("option");
x.appendChild( document.createTextNode("smith"));
x.value = "jones";
document.getElementById("xx").appendChild(x);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment