select选择最近3年的年份查询

<select id="selectyear" ></select>
 
/*****自动给select 赋值显示最近3年的年份*****/
    window.onload = function(){
        for(var i=0;i<3;i++){
            $("#selectyear").append("<option value='' disabled selected hidden>请选择年份</option><option value='"+(new Date().getFullYear()-i)+"'>"+(new Date().getFullYear()-i)+"</option>");
        }
    }

 

posted @ 2021-02-23 10:55  小夜猫啊  阅读(309)  评论(0编辑  收藏  举报