JavaScript Implementation select Add option

  • 2020-07-21 06:45:17
  • OfStack

JavaScript adds option to select

<!DOCTYPE html>
<meta charset="utf-8">
<title> The test file </title>
window.onload = function(){
  // create select controls 
  var _select = document.createElement("SELECT");
  // Add a option 
  for(var i=1; i<=10; i++){
    var _option = new Option(i,i);
  // The handler when the selected value changes 
  _select.onchange = function(){
    alert(_select.value); // take select Control is the selected value 


This is the end of this article, I hope you enjoy it.

Related articles: