jQuery特定日期全站变灰
发布时间:2021-03-06 18:12:03
来源:
在一些特殊的日子里,我们可能会用到这段代码。
<script>
$(document).ready(function() {
var today = new Date();
var todayMonth = today.getMonth() + 1;
var todayDate = today.getDate();
function gray(){
$('body').css({
"-webkit-filter":"grayscale(100%)",
"-moz-filter":"grayscale(100%)",
"-ms-filter":"grayscale(100%)",
"-o-filter":"grayscale(100%)",
"filter":"progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)",
"_filter":"none"});
};
if (todayMonth == 4 && todayDate == 4) {gray()}; // 4 月 4 日
if (todayMonth == 6 && todayDate == 4) {gray()};
if (todayMonth == 12 && todayDate == 13) {gray()}; // 12 月 13 日
})
</script>