jQuery特定日期全站變灰
發(fā)布時間: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>