使用鼠标选择日期时,jQuery UI Datepicker失去焦点 [英] JQuery UI Datepicker loses focus when selecting date with mouse
本文介绍了使用鼠标选择日期时,jQuery UI Datepicker失去焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将JQuery ui与datepicker一起使用,当用户使用Tab键浏览字段时,他们会适当地弹出日历.
I am using JQuery ui with datepicker and when a user tabs on to a field, they appropriately get the calendar pop up.
- 用户标签(通过键输入字段
- 用户通过单击鼠标选择日期
- 用户标签
- Tabindex从一个开始(在表格的开头)
这是代码. (可能还会设置标签索引)
Here is code. (May also have the tab index set)
<input type="text" name="demo" />
<input type="text" class="date" />
jquery代码是:
The jquery code is:
$(".date").datepicker();
关于我可能如何解决此问题的任何建议(对最短的解决方案有好处)?
Any suggestions on how I might go about solving this issue (bonus to shortest solution)?
推荐答案
订阅onClose
或onSelect
事件:
$("#someinput").datepicker(
{
// other options goes here
onSelect: function ()
{
// The "this" keyword refers to the input (in this case: #someinput)
this.focus();
}
});
或者对于onClose
:
$("#someinput").datepicker(
{
onClose: function ()
{
this.focus();
}
});
这篇关于使用鼠标选择日期时,jQuery UI Datepicker失去焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文