选择日期后,使用Jquery的Datepicker失去对文本框的关注. [英] Datepicker using Jquery loses focus to the textbox after date selected.
本文介绍了选择日期后,使用Jquery的Datepicker失去对文本框的关注.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Jquery的日期选择器在选择日期后将焦点移至文本框.我使用jquery-UI-1.9.2.When一个日期被选择的焦点不来textbox.Any溶液?
Datepicker using Jquery loses focus to the textbox after date selected. I am using jquery-ui-1.9.2.When a date is selected the focus not coming to the textbox.Any solution?
推荐答案
尝试使用以下代码.
HTML代码:
<input type="text" id="date"/>
JQuery:
$("#date").datepicker({
onClose: function () {
$(this).focus();
}
});
编辑:上面的代码在IE中有问题,日期选择器未关闭.在此博客中,您可以找到更多信息.
The above code has a problem in IE, the datepicker is not getting closed. Here in this blog you can find the more information.
<script language='javascript' src="jquery-migrate-1.2.1.js"></script> // download and add this
$("#date").datepicker({
/* fix buggy IE focus functionality */
fixFocusIE: false,
onClose: function(dateText, inst) {
this.fixFocusIE = true;
this.focus();
},
beforeShow: function(input, inst) {
var result = $.browser.msie ? !this.fixFocusIE : true;
this.fixFocusIE = false;
return result;
}
});
这篇关于选择日期后,使用Jquery的Datepicker失去对文本框的关注.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文