在JQuery UI日历中只显示几年 [英] Display only years in JQuery UI Calendar

查看:391
本文介绍了在JQuery UI日历中只显示几年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JQuery UI日历中显示或显示年份?

how can i show or display only years in JQuery UI Calendar? I need to do a dropdown list with years without taking care the month, just years.

提前感谢

推荐答案

    $( "#datepicker" ).datepicker({
        changeMonth: false,
        changeYear: true
    });

http://jqueryui.com/demos/datepicker/#dropdown-month-year

或者,如果您只需要一个年的列表,你可以生成它没有jQueryUI:

Alternatively, if you just want a list of years, you can generate it without jQueryUI:

var i,yr,now = new Date();
for (i=0; i<10; i++) {
    yr = now.getFullYear()+i; // or whatever
    $('#select-year').append($('<option/>').val(yr).text(yr));
};

这篇关于在JQuery UI日历中只显示几年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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