从JQUERY日期选择器获取价值
如果我想通过将JQUERY UI datepicker附加到像$("div#someID").datepicker()
这样的DIV来内联显示-如何访问所选日期?我假设如果它没有绑定到INPUT
,那么它将不会与表单一起提交.
If I want to display the JQUERY UI datepicker inline by attaching it to a DIV like $("div#someID").datepicker()
- how do I access the chosen date? I assume if it's not bound to an INPUT
then it won't be submitted with the form.
我想作为后续工作,如果我需要将其绑定到INPUT元素,是否有一种方法可以控制datepicker相对于INPUT元素的位置?如果我希望日期选择器显示在元素的上方或侧面,而不是在元素的下方,我该怎么做?
I guess as a followup, if I need to bind it to an INPUT element, is there a way to control the positioning of the datepicker relative to the INPUT element? If I wanted the datepicker to appear above or to the side of the element rather than below it, how would I do that?
如果这个答案确实很明显,请原谅我.
Forgive me if this answer is somewhere really obvious.
如果要在用户选择日期时获取日期,可以执行以下操作:
If you want to get the date when the user selects it, you can do this:
$("#datepicker").datepicker({
onSelect: function() {
var dateObject = $(this).datepicker('getDate');
}
});
我不确定您问题的第二部分.但是,您是否尝试过使用样式表和相对位置?
I am not sure about the second part of your question. But, have you tried using style sheets and relative positioning?