将jquery datepicker位置设置为文本字段的顶部 [英] Set jquery datepicker position to top of text field
本文介绍了将jquery datepicker位置设置为文本字段的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery datepicker显示在测试字段下方.一段时间后它会在文本字段的顶部.但我想始终在测试字段的顶部显示日期选择器.怎么做?
Jquery datepicker shows at under the test field. Some time it will top of text field. But I want show the datepicker always in top of the test field. How to do it?
推荐答案
以下代码将日历始终放置在输入字段的顶部.
The following code will position the calendar always on top of input field.
$('.txtDate').datepicker({
beforeShow: function (textbox, instance) {
var txtBoxOffset = $(this).offset();
var top = txtBoxOffset.top;
var left = txtBoxOffset.left;
var textBoxWidth = $(this).outerWidth();
console.log('top: ' + top + 'left: ' + left);
setTimeout(function () {
instance.dpDiv.css({
top: top-190, //you can adjust this value accordingly
left: left + textBoxWidth//show at the end of textBox
});
}, 0);
}});
这篇关于将jquery datepicker位置设置为文本字段的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文