简体   繁体   English

对jQuery Datepicker使用getDate函数

[英]using the getDate function for JQuery Datepicker

Hi :) Sorry if my question sounds a bit stupid but I am not the most experienced with javascript.. 嗨:)对不起,如果我的问题听起来有点愚蠢,但我不是最有经验的javascript。

I have done the code to have a JQuery Datepicker calendar displayed on my page and that works fine. 我已经完成了将JQuery Datepicker日历显示在页面上的代码,并且工作正常。 But I want to store the date which is selected in a variable called $HistoryDate..I have put the following code between the tags; 但是我想将选择的日期存储在名为$ HistoryDate的变量中。

    <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>

I have looked up the getDate function and Im guessing its something along the lines of; 我查了一下getDate函数,我猜测它的大致含义是:

var HistoryDate;
         HistoryDate = $("#datepicker").datepicker('getDate');

Im tried that method, by putting the above two lines in the head tags aswell but when I try echo HistoryDate() in the body I get nothing? 我通过将上述两行也放在head标签中来尝试了该方法,但是当我尝试在主体中回显HistoryDate()时,我什么也没得到? Any suggestions? 有什么建议么?

var HistoryDate;
$(function() {
    $("#datepicker").datepicker({
        onSelect: function(){ 
            HistoryDate = $(this).datepicker('getDate'); 
        }
    });  
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM