Created
August 24, 2015 22:20
-
-
Save EricDavies/c2c9fbfc61a659ea1e53 to your computer and use it in GitHub Desktop.
adding a label to a select option.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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