如何将onChange事件添加到JQuery.DatePicker的下拉框中 [英] How to add onChange event to dropdown boxes of JQuery.DatePicker

查看:181
本文介绍了如何将onChange事件添加到JQuery.DatePicker的下拉框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:小提琴

我想要的是将 onChange 事件添加到 datepicker 的下拉框中,以便我能够从日历中选择一个新值,在上面的文本框中捕获所选的月/年。

What I want, is to add an onChange event to the dropdown boxes of the datepicker so that I will be able to capture the selected month/year in the text box above as a new value is selected from the calendar.

PS:检查相关的下拉框,已经有一个 c> onChange 命令分配给

PS: Inspecting the relevant dropdown boxes, there is already an onChange command assigned that looks like

onchange="DP_jQuery_1353406309923.datepicker._selectMonthYear('#datepicker', this, 'M');"

我不想覆盖这个。

提前感谢

推荐答案

使用 onChangeMonthYear 选项:


onChangeMonthYear


datepicker移动时调用到新的一个月和/或一年。该函数接收所选择的年份,月份(1-12),日期签名实例作为参数。这是指相关的输入字段。

Called when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. this refers to the associated input field.




$(function() {
    $( "#datepicker1" ).datepicker({
      changeMonth: true,
      changeYear: true,
      dateFormat: 'MM yy',
      altField: "#id",
      altFormat: "mm/yy",
      onChangeMonthYear: function(year, month, oDatepicker) {
        alert('Year: ' + year + ', Month: ' + month);
      }
    });
});​

您的小提琴,更新: http://jsfiddle.net/ff6Ex/1/

这篇关于如何将onChange事件添加到JQuery.DatePicker的下拉框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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