将内联jquery datepicker与输入字段相结合? [英] Combine inline jquery datepicker with an input field?

查看:92
本文介绍了将内联jquery datepicker与输入字段相结合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用 $('div')。datepicker()来获取一个内联的日期戳,但是如何显示 datepicker 在其输入字段下固定内联

I know that I can use $('div').datepicker() to get an inline datepicker, but how do I show the datepicker fixed inline underneath its input field?

alt 字段选项不起作用对我来说,因为我想要 datepicker 也对输入字段中输入的日期做出反应。

The alt field option does not work for me because I want the datepicker to also react on a date entered into the input field.

我需要类似于以下伪代码:

I would need something like the following pseudocode:

<inputfield type="text" id="d" >
<div id="z"></div>  
<script> $('#z').datepicker().bindToInputfield($('#d')) </script>


推荐答案

尝试这样:工作演示 http://jsfiddle.net/KRFCH/

The code> altField 选项将链接到您想要的第二个字段! http://jqueryui.com/datepicker/#alt-field

The altField option will link to the second field you want! http://jqueryui.com/datepicker/#alt-field

现在注意:输入中的任何更改将反映在更改的日期列表中

Now note: any change in the input will reflect in the datepicker on change

这应该适合您的原因:)

代码

$('#z').datepicker({
    inline: true,
    altField: '#d'
});

$('#d').change(function(){
    $('#z').datepicker('setDate', $(this).val());
});

这篇关于将内联jquery datepicker与输入字段相结合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆