如何在JQuery datepicker中禁用特定日期? [英] how to disable specific days in JQuery datepicker ?
本文介绍了如何在JQuery datepicker中禁用特定日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的jquery日期选择器中禁用所有星期日,星期一和星期三。我正在尝试使用以下代码示例 -
I want to disable all the Sunday,Monday and Wednesday from my jquery date-picker. I am trying to do this using the following code sample-
jQuery(document).ready(function($) {
$(".datepicker").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 1), ''];
}
})
});
此代码禁用日历中的所有星期一。如何禁用所有星期日和星期三?
This code disable all Mondays from the calender. How can i disable all Sunday and Wednesdays too?
推荐答案
){
( .datepicker)。datepicker({
beforeShowDay: function (日期){
var day = date.getDay();
return [(day!= 1 ),' '];
}
})
});
(".datepicker").datepicker({ beforeShowDay: function(date) { var day = date.getDay(); return [(day != 1), '']; } }) });
此代码禁用日历中的所有星期一。如何禁用所有星期日和星期三?
This code disable all Mondays from the calender. How can i disable all Sunday and Wednesdays too?
使用beforeShowDay属性:
Make use of beforeShowDay property:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script>
这篇关于如何在JQuery datepicker中禁用特定日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文