1:
var year = document.getElementById ("year");
var date = new Date();
for ( var i = 1890; i < date.getFullYear() + 1; i++)
{
var opt = document.createElement ("option");
opt.value = i;
opt.innerText = i;
year.appendChild (opt);
}
1.1:获取值
1:拿到select对象: var myselect=document.getElementById("test");
2:拿到选中项的索引:var index=myselect.selectedIndex ;// selectedIndex代表的是你所选中项的index
3:拿到选中项options的value: myselect.options[index].value;
4:拿到选中项options的text: myselect.options[index].text
2: