我是靠谱客的博主 落后金毛,这篇文章主要介绍jq随机加载背景图,现在分享给大家,希望可以做个参考。

刷新页面随机加载图片

 <style>
        body{
                       padding:0;
                       background-attachment: fixed;
                       background-clip: border-box;
                       background-color: #666666;
                       background-origin: padding-box;
                       background-position: center top;
                       background-repeat: no-repeat;
                       background-size: cover;
                       width: 100%;
                       background-image:url("");}
       </style>
</head>
<body>
    
    <script src="./css/jquery-3.5.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            var random_bg=Math.floor(Math.random()*3+1); //三张图轮换
            var bg='url(./images/new_feed/bg_'+random_bg+'.jpg)';
            $("body").css("background-image",bg);
   });
   </script>

图片放在images文件夹下new_feed文件夹中,命名以bg_(x),格式

最后

以上就是落后金毛最近收集整理的关于jq随机加载背景图的全部内容,更多相关jq随机加载背景图内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部