<html>
<body>
<p>Click the button to create a SELECT and an OPTION element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.createElement("SELECT");
x.setAttribute("id", "mySelect");
document.body.appendChild(x);
var z = document.createElement("option");
z.setAttribute("value", "volvocar");
var t = document.createTextNode("Volvo");
z.appendChild(t);
document.getElementById("mySelect").appendChild(z);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_select_create by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:08:08 GMT -->
</html>