[英]jQuery UI Datepicker be made to disable weekends and holidays?
我已经看到一个确切的问题正在回答,但是问题是,我绝对不知道将此处显示的代码粘贴到我的工作中。 在编程方面,我真的是个菜鸟。
如果有人迫切需要我的日历来启迪我,我将不胜感激。 :(
非常感谢。
var holidays= ["2014-7-30","2015-07-29","2013-03-16"]
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return [$.inArray(string, holidays) == -1];
}
else
return noWeekend;
}
});
我会尝试回答:
如何开始- 在这里
您将需要theese :(将其链接到页面顶部。)
- jQuery库:Datepicker需要包括jQuery。
- JavaScript:ui.core.js和ui.datepicker.js
- CSS主题:使用ThemeRoller创建主题
您可以在此处找到有关基础的出色演示
<script>
$(function() {
/*function that makes appear datepicker + you add option to disable Weekends*/
$(".selector").datepicker({ beforeShowDay: $.datepicker.noWeekends })
});
</script>
<div id="demo">
<p>Date: <input class="selector" type="text"></p> //input field that calls the function
</div>
2件事情:
我可以建议您像往常一样做-运行了很多教程,也是最重要的事情- 实验 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.