我想在相同的日期每年使数据采集单元格有不同的颜色。如果月份为12(12月),而日期为18至31。我不想要一个应该是不同颜色的特定日期数组。
我试过这样做:
beforeShowDay: function(date) {
var day = date.getUTCDate();
var month = date.getUTCMonth();
return [!( (day == 17 && month == 11) || (day == 18 && month == 11) || (day == 19 && month == 11) || (day == 20 && month == 11) || (day == 21 && month == 11) || (day == 22 && month == 11) || (day == 23 && month == 11) || (day == 24 && month == 11) || (day == 25 && month == 11) || (day == 26 && month == 11) || (day == 27 && month == 11) || (day == 28 && month == 11) || (day == 29 && month == 11) || (day == 30 && month == 11) )];
}
但这只会使细胞失效。我不想让他们残疾
发布于 2018-10-10 13:18:26
您希望使用jQuery更改所有一年12月月份的所有18到31天的颜色
请检查以下代码:
$('#mydate').datepicker({
beforeShowDay: colorize
});
function colorize(date) {
if((date.getMonth() + 1)!=12) return [true, ""];
if(date.getDate()<18) return [true, ""];
return [true, "cool"];
}
.cool a.ui-state-default {
background-color: #03a9f4;
background-image: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<p>See December month of any year:</p>
<input type="text" id="mydate" placeholder="click here" />
https://stackoverflow.com/questions/52740833
复制相似问题