jQuery datepicker上的esc键事件 [英] jquery datepicker on esc key event

查看:100
本文介绍了jQuery datepicker上的esc键事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户打开日期选择器后,点击键(例如,keyCode == 27)时,我正在尝试在日期选择器的输入框中输入日期值.

I'm trying to put a date value in the input box for the date picker when the user click on the key ESC (e.keyCode == 27) once he as open the datepicker.

我的测试用例:

1)单击输入框,显示日期选择器;

1) Click on the input box, the date picker show up;

2)用户决定通过单击esc键取消选择.

2) The user decide to cancel the selection by clicking on the esc key.

3)由于他没有选择任何日期,因此以下日期应默认输入(01/01/2011)在输入框中.

3) The following date should be then put as default (01/01/2011) in the input box since he has not selected any date.

请分叉我的小提琴

Please fork my Fiddle

推荐答案

$("#input").keyup(function(e) {
    if (e.keyCode == 27) {
        $("#input").val("01/01/2011");
    }
});

在此处查看其运行情况: http://jsfiddle.net/nayish/SYwpy/46/

See it in action here: http://jsfiddle.net/nayish/SYwpy/46/

这篇关于jQuery datepicker上的esc键事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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