开发者

JQuery UI DatePicker - How to manually open a datepicker

How can a manually op开发者_如何学运维en a datepicker for js code?


To show the datepicker associated to the input with id 'your_elem', you would use something like this:

jQuery('#your_elem').datepicker("show");


$('#datepickerid').focus() should do the trick.


for me, neither of the suggested solutions work. the date picker opens, but then immediately it closes. so I solved this by using:

setTimeout('$("#datepicker_element").focus();', 320);

hope this helps someone


I had this problem (datepicker was a part of a Drupal module in this case) and for me worked this:

$('input.date').focus();
$('input.date').click();

It didn't work when only $('input.date').click(); was used.


Did work for me:

    setTimeout(function(){$("input#element_id").focus();}, 200);


$(function () {
    $('#DatePicker').datepicker({
        duration: '',
        showTime: true,
        constrainInput: false,
        maxDate: '+1y',
        minDate: '-0d',
        defaultDate: ''
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜