We can create an <option> element via the document.createElement()
method:
var x = document.createElement("OPTION");
Click the button to create an OPTION element.
<!DOCTYPE html> <html> <body> <select id="mySelect"> </select>//from w ww .j a v a2 s. c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.createElement("OPTION"); x.setAttribute("value", "javascript"); var t = document.createTextNode("Javascript"); x.appendChild(t); document.getElementById("mySelect").appendChild(x); } </script> </body> </html>