无法获取jQueryUI datepicker选项在beforeShowDay之前工作.
我尝试了不同的帮助主题,但是我找不到它.
我收到这个错误
Uncaught TypeError: Cannot read property ‘0’ of undefined
这是我的JS.但它似乎不起作用
<script type="text/javascript"> jQuery(document).ready(function () { var your_dates = [new Date(13,5,5),new Date(13,10)]; jQuery("div#event-calender").datepicker({ beforeShowDay: function (date) { if (jQuery.inArray(date.toString(),your_dates) != -1) { return [true,'highlight']; } } }); }); </script>
解决方法
您需要始终返回一个数组,而不仅仅是条件匹配时.
beforeShowDay
Type: Function( Date date )
A function that takes a date as a parameter and must return an array
jQuery(document).ready(function () { var your_dates = [new Date(13,10)]; jQuery("div#event-calender").datepicker({ beforeShowDay: function (date) { var arr; if (jQuery.inArray(date.toString(),your_dates) != -1) { arr = [true,'highlight']; }else { arr = [true,'']; } return arr; } }); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。