7b2主题网站夜间模式

7b2主题网站夜间模式


7b2主题网站夜间模式

网站footer.php引入css文件

js:

(function(){
    if(document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$)|^.*$/, "$1") === ''){
        if(new Date().getHours() > 20 || new Date().getHours() < 6){
            document.body.classList.add('night');
            document.cookie = "night=1;path=/";
            $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
        }else{
            document.body.classList.remove('night');
            document.cookie = "night=0;path=/";
            $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
        }
    }else{
        var night = document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$)|^.*$/, "$1") || '0';
        if(night == '0'){
            document.body.classList.remove('night');
            $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
        }else if(night == '1'){
            document.body.classList.add('night');
            $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
        }
    }
})();
function switchNightMode(){
    var night = document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$)|^.*$/, "$1") || '0';
    if(night == '0'){
        document.body.classList.add('night');
        document.cookie = "night=1;path=/";
        $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
    }else{
        document.body.classList.remove('night');
        document.cookie = "night=0;path=/";
        $(".logo img").attr("src","https://img.ahap.cn/logo/logo.svg");
    }
}

按钮切换,按钮代码:

<a href="javascript:switchNightMode()">点我</a>

下载权限
查看
  • K
    免费下载
    评论并刷新后下载
    登录后下载
  • {{attr.name}}:
您当前的等级为
登录后免费下载登录 小黑屋反思中,不准下载! 评论后刷新页面下载评论 支付以后下载 请先登录 您今天的下载次数(次)用完了,请明天再来 支付积分以后下载立即支付 支付以后下载立即支付 您当前的用户组不允许下载升级会员
您已获得下载权限 您可以每天下载资源次,今日剩余
声明:本站部分文章来源于网络,如有危害到您的合法权益请联系客服

给TA打赏
共{{data.count}}人
人已打赏
7b2

7b2主题全站字体更换

2022-3-23 2:17:34

7b2WP技术WP美化

7b2主题弹窗登录美化

2022-3-25 18:29:25

2 条回复 A文章作者 M管理员
  1. 小R

    6666666

  2. 大林

    666

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索