需要使 jquery-ui-datepicker 中的每个日期成为带有日期的自定义超链接

Need to make each date in jquery-ui-datepicker a custom hyperlink with the date

我正在使用 jquery 日期选择器,需要将日历 link 中的每一天都添加到一个页面中。

例如,如果您单击日期 1 月 12 日,它将 link 到 http://myurl.com/12-01-17 or for 2 Feb it will link to http://myurl.com/2-02-17

    jQuery( function() {
    jQuery("#datepicker").datepicker({
                    prevText: "<",
                    nextText: ">",
                    dayNamesMin: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
                    dateFormat: 'd MM yy',
                    showOtherMonths: true,
                    selectOtherMonths: true,
    });
});


<div id="datepicker"></div>

<a href="http://my-url.com/DATEPICKER DATE HERE"></a>

只需为日期选择器使用 onSelect 选项。

$(function(){
  $( "#datepicker" ).datepicker({
    dateFormat: "dd-mm-yy",
    onSelect: function (date) {
      window.location="http://my-url.com/"+date.toString();
      //date.toString() is now in dd-mm-yyyy format, change it to meet your requirements
    }
  });

});
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Date: <input id="datepicker" type="text"></p>
<a id="link" href="http://my-url.com/DATEPICKER DATE HERE">click me</a>