jQuery UI日期选择器-在选择日期时更新另一个日期选择器 [英] jQuery UI date picker - updating another date picker on selecting a date

查看:109
本文介绍了jQuery UI日期选择器-在选择日期时更新另一个日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个使用Jquery UI的日期选择器.如果用户从日期选择器1中选择一个日期,如何获取具有相同日期的自动更新日期选择器2?

I have 2 date pickers using the Jquery UI. If the user selects a date from date picker 1, how can I get it to update date picker 2 automatically with the same date?

我认为这可能很简单,但是我尝试了一些尝试,但似乎没有任何效果.

I think this might be quite simple, but I've tried a few things and nothing seems to work.

谢谢.

推荐答案

日期选择器本质上是一个文本输入元素.您可以在第一个输入元素上使用jquery更改处理程序来捕获其更改时的内容,然后只需选择第二个输入元素并使用jquery val更新值即可.

The date picker is essentially a text input element. You can use the jquery change handler on the first input element to grab its contents when they change, then simply select the second input element and update the value using jquery val.

http://api.jquery.com/change/ http://api.jquery.com/val/

http://api.jquery.com/change/ http://api.jquery.com/val/

类似的东西:

$("#firstdatepicker").change(  function() {
   $("#seconddatepicker").val($(this).val());
});

这篇关于jQuery UI日期选择器-在选择日期时更新另一个日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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