jQuery Ui日历,添加所选日期的链接?

您好我使用jQuery UI日历来显示我的事件,设计很光滑,它完美地工作。

但是,我想添加指向我的活动的链接(在我的日历上突出显示的日期),我找不到任何可以帮助我编写代码的内容。

这是我的代码,用于选择我想要的日期并添加事件名称的工具提示:

$("#div-calendar").datepicker({ beforeShowDay: highlightDays }); var dates = //Array Containing Events dates, names and link. //Highlight days on the calendar function highlightDays(date) { for (var i = 0; i < dates.length; i++) { if (date - dates[i][0] == 0) { return [true, '', dates[i][1]]; } } return [false]; } 

我找到的唯一语法是:

 return [true, '', dates[i][1]]; 

第一个参数是高亮显示日期,第二个参数是自定义css,第三​​个是工具提示。

那么在那些日子可以添加链接吗? 就像我用工具提示做的一样。

谢谢。

好吧这很俗气,但我找不到更好的解决方案。 我使用class参数传递值。

它在jQuery日期选择器日历上显示事件,它显示每个事件的自定义工具提示,单击时,它会显示该事件的详细页面。

 $("#div-calendar").datepicker({ beforeShowDay: highlightDays, onSelect: SelectedDay }); dates = //Array Containing Events [date, name, id] of each event. (from ajax) //Highlight days on the calendar, the array *dates* in this example. function highlightDays(date) { for (var i = 0; i < dates.length; i++) { if (date - dates[i][0] == 0) { //1st parameter is highlight the date, 2nd is custom css and 3rd is tooltip. return [true, 'ID=' + dates[i][2], dates[i][1]]; } } return [false]; } //When a highlighted day is clicked function SelectedDay(date, inst) { //hack so the UI is updated see : http://stackoverflow.com/questions/4854635/jquery-datepicker-onselect-event-fired-to-early window.setTimeout(function () { //Get the clicked cell classes var classes = inst.dpDiv.find('.ui-datepicker-current-day a').parent().attr("class").split(" "); //loop through classes, read the ID=x class and extract 'x', then redirect to desired page for (var i in classes) { if (classes[i].substring(0, 3) == "ID=") { location.href = "/mypage.php?ID=" + classes[i].substring(3) } } }, 0); } 

可以使用选择属性。 当有人点击某个日期时,您可以查看该日期是否包含与之相关的信息。

此外,您可以尝试使用jQuery wrap将单个html日期元素与您的链接包装在一起