我正在努力获得一个看起来和行为与分配给现场输入字段的内联日期选择器完全相同的年历。所以我创建了这个块
<div class="box_content">
<div class="yearCal" id="cal2"><!-- this will receive the calendar --></div>
</div>
并将 datepicker 对象分配给 id 为“cal2”的元素。这使我的日历小部件显示 12 个月。每个 td 元素如下所示:
<td about="I receive class 'free' or 'booked' from 'BeforeShowDay' handler">
<a about="I am the element catching the click and need the parent class"></a>
</td>
我使用此代码测试配置了 datepicker 的 onSelect 函数
onSelect: function(dateText, inst) {
console.debug( jQuery(this).parent().attr('class') );
}
但是当我点击一个日历日时,我会得到 id 'box_content'。无论我尝试什么,我都没有得到父母的元素。但是我需要得到它,因为当小部件被渲染时,每个 td 元素都会获得一个“免费”或“预订”类,并且根据它的类,我必须执行一些数据库操作。
你能告诉我怎么做吗?