最佳答案
HTML
原文链接:https://www.f2er.com/js/429685.html
JavaScript的
var myselect = document.getElementById("year"),year = new Date().getFullYear();
var gen = function(max){do{myselect.add(new Option(year++,max--),null);}while(max>0);}(5);
一点点更好的JavaScript功能:
var myselect = document.getElementById("year"),startYear = new Date().getFullYear()
count = 5;
(function(select,val,count) {
do {
select.add(new Option(val++,count--),null);
} while (count);
})(myselect,startYear,count);