如何获取jquery datepicker的当前活动实例 [英] How to get current active instance of jquery datepicker

查看:125
本文介绍了如何获取jquery datepicker的当前活动实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在绑定到输入控件的单页上有多个datepicker控件。
当我点击链接到该输入的任何输入控件datepicker控件变得可见。

I have multiple datepicker controls on single page binded to input controls. When I click on any of the input control datepicker control linked to that input gets visible.

现在我想获取当前的datepicker实例的输入正在显示另一个JS事件。
可以吗?

Now I want to get input for which the current instance of datepicker is being shown on another JS events. Is it possible?

推荐答案

您可以尝试使用 $。datepicker._getInst target)方法来获取页面上的任何特定日期戳。你只需要传递一个目标元素,你可以通过使用document.getElementById (不要使用JQuery )传递id来实现,否则它将返回undefined)。

You can try using the $.datepicker._getInst(target) method to get any specific datepicker on your page. You just have to pass in a target element, which you can do so by just passing the id using document.getElementById (don't use JQuery or it will return undefined).

所以这样:

var id = document.getElementById('someId'); 
//replace someId with the id of the datepicker currently visible.  
var inst = window.$.datepicker._getInst(id);

如果您尝试获取一个内联元素的datepicker的当前实例,这是特别有用的(不附加到输入)。

This is especially helpful if you are trying to get the current instance of a datepicker that's an inline element (not attached to an input).

这篇关于如何获取jquery datepicker的当前活动实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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