JavaScript:jQuery Datepicker - 简单突出显示特定日期,谁可以提供帮助? (来源内)
我想使用日期选择器来突出显示特定日期。这是我的最新代码:
<script type="text/javascript">
var dates = [30/04/2010, 01/05/2010];
$(function(){
$('#datepicker').datepicker({
numberOfMonths: [2,3],
dateFormat: 'dd/mm/yy',
beforeShowDay: highlightDays
});
function highlightDays(date) {
for (var i = 0; i < dates.length; i++) {
if (dates[i] == date) {
return [true, 'highlight'];
}
}
return [true, ''];
}
});
</script>
我的 CSS 是:
#highlight, .highlight {
background-color: #cccccc;
}
好吧,日历出现了,但没有突出显示任何内容。我的代码问题出在哪里? 如果有人能提供帮助那就太好了。
另一个选项/解决方案可能是:禁用所有日期,但仅使数组中的日期可用。
谢谢!
i want to use the Datepicker for highlighting specific dates. Here is my latest code:
<script type="text/javascript">
var dates = [30/04/2010, 01/05/2010];
$(function(){
$('#datepicker').datepicker({
numberOfMonths: [2,3],
dateFormat: 'dd/mm/yy',
beforeShowDay: highlightDays
});
function highlightDays(date) {
for (var i = 0; i < dates.length; i++) {
if (dates[i] == date) {
return [true, 'highlight'];
}
}
return [true, ''];
}
});
</script>
my CSS is:
#highlight, .highlight {
background-color: #cccccc;
}
Well the calendar comes up, but there is nothing highlighted. Where is the problem in my code?
If anyone could help that would be great.
Another option/solution could be: disable all dates, but make available only dates in an array.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我们告诉您一些问题...
1 . var 日期 = [30/04/2010, 01/05/2010];
不会按预期存储您的日期...它将进行数学运算...
2. 将其更改为字符串,但采用以下格式:
mm/dd/yy
因此,您应该具有以下内容:
3. 使用此功能:
4. CSS 为:
5. 演示
let tell you some of the problems...
1 . var dates = [30/04/2010, 01/05/2010];
would not store your dates as expected... it will do math operations...
2. change it to string but in this format:
mm/dd/yy
so, you should have something like:
3. use this function:
4. CSS as:
5. demo
时区有问题。
There is problem with timezone.