How to get current active instance of jquery datepicker

狂风中的少年 提交于 2019-12-14 04:27:21

问题


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.

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


回答1:


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).

So like so:

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

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).



来源:https://stackoverflow.com/questions/34088788/how-to-get-current-active-instance-of-jquery-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!