是否有 jquery 下拉年份选择器 [英] is there a jquery dropdown year selector

查看:16
本文介绍了是否有 jquery 下拉年份选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个 jQuery 插件可以自动创建一个下拉年份选择器(这是一个选择"元素,其中填充了从当前开始到给定年份的所有年份)?

is there a jQuery plugin that creates automatically a dropdown year selector (that is a "select" element poulated with all years starting from current and dating back to a given year)?

我不需要日/月(否则我会使用日期选择器),我只需要年份!

I don't need day/month (otherwise i'd have used the datepicker), i just need the year!

提前致谢

推荐答案

刚刚呢:

<select name="yearpicker" id="yearpicker"></select>

然后:

for (i = new Date().getFullYear(); i > 1900; i--)
{
    $('#yearpicker').append($('<option />').val(i).html(i));
}

这篇关于是否有 jquery 下拉年份选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆