嗨,即时通讯使我的背景图像随机出现。但是现在我希望它每30或40秒更换一次图像。现在我的代码如下所示:如何让功能每30秒运行一次?
#background{
position: fixed;
height: 100%;
width: 100%;
z-index: -100px;
<?php
$count = rand(1, 8);
$hello = "background: url('img/backImg/". $count ."') center center;";
echo ($hello);
?>
background-repeat:no-repeat;
background-color: #d8d8d8;
background-size: cover;
}
所以我想$count
串采取了随机数每30秒。
你需要ajax:http://www.w3schools.com/ajax/或者与php无关的东西。 – bozdoz
您需要ajax或jquery的javascript –
您无法在服务器上使用PHP来做到这一点。您需要发送在浏览器内运行的JavaScript代码。 –