js 年份选择

<select class="drop-down">

</select>

<script type="text/javascript">
var dropDown = document.getElementsByClassName('drop-down')[0];
for(var i = 1970;i<2019;i++){
var textnode = document.createTextNode(i+"年");
var options = document.createElement('option');
options.appendChild(textnode);
dropDown.appendChild(options);
}
</script>

posted @ 2018-05-21 18:03  阳光下的三叶草  阅读(322)  评论(0编辑  收藏  举报