使用JQuery Datepicker来显示月份 [英] Using JQuery Datepicker To Only Show Months

查看:380
本文介绍了使用JQuery Datepicker来显示月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用 JQuery UI Datepicker 来允许用户选择一个特定的月份,而不用选择该月份的某一天。 Datepicker上的前进和前一按钮将使用户使用不同的年份,而不是不同的月份

I'm looking to be able to use the JQuery UI Datepicker to allow a user to select a particular month, without the option to select a particular day in that month. The forward and previous buttons on the Datepicker would take the user to different years, instead of different months.

Datepicker文本框中显示的格式需要为 mm / yyyy 。如何才能做到这一点?

The format that appears in the Datepicker textbox needs to be mm/yyyy. How can this can be done?

推荐答案

为什么不用几个月和一年的2个下拉列表?如下:

Why not making 2 dropdowns with months and year? something like:

var Months = ["January","February","March","April","May","June","July","August","September",  "October","November","December"];
var $selM = $('<select />');
$.each(Months,function(ind,item){

    $selM.append($('<option />').val(ind + 1).text(item));
});
$('span#Months').append($selM);

您可以通过以下方式获得当前年份:

as for year you can get the current year by :

var now = new Date();
var year        = now.getYear();

然后再创建一个DDL多年的范围。

then making another DDL for years with the range that you'd like to.

这篇关于使用JQuery Datepicker来显示月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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