jquery datepicker on esc key event

不羁岁月 提交于 2020-01-21 19:14:52

问题


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.

My test case:

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

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

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


回答1:


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

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



来源:https://stackoverflow.com/questions/7163493/jquery-datepicker-on-esc-key-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!