1. Insert option
1. DOM method
var oSelectYear = ("SelectYear");
var op = ("option");
= "2010";
= "2010";
(op);
2. New Option method
var oSelectMonth = ("SelectMonth");
(new Option(1, 1));
(new Option(2, 2));
2. Clear option
var oSelectMonth = ("SelectMonth");
= 0; //Clear options in Select
3. Set the default selection option
var oSelectMonth = ("SelectMonth");
// = 1; //Method 1: Select the second item by default
//setTimeout(function() { = 1; }, 0); //Use setTimeout delay is to prevent dom rendering problems
// [1].selected = true; //Method 2
[1].setAttribute("selected", "true"); //Method 3: It is recommended to use setAttribute to set
1. DOM method
var oSelectYear = ("SelectYear");
var op = ("option");
= "2010";
= "2010";
(op);
2. New Option method
var oSelectMonth = ("SelectMonth");
(new Option(1, 1));
(new Option(2, 2));
2. Clear option
var oSelectMonth = ("SelectMonth");
= 0; //Clear options in Select
3. Set the default selection option
var oSelectMonth = ("SelectMonth");
// = 1; //Method 1: Select the second item by default
//setTimeout(function() { = 1; }, 0); //Use setTimeout delay is to prevent dom rendering problems
// [1].selected = true; //Method 2
[1].setAttribute("selected", "true"); //Method 3: It is recommended to use setAttribute to set