更新时间:2022-06-10 05:03:23
试试这样..
Try like this..
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
var loading = function () {
var totalCount = 6;
var num = Math.floor(Math.random() * totalCount) + 1
document.body.background = 'images/' + num + '.jpg'
}
</script>
</head>
<body onload=loading();>
<form id="form1" runat="server">
</form>
</body>
</html>
尝试
Try
<html>
<head>
<script type="text/javascript">
var totalCount = 6;
function ChangeIt()
{
var num = Math.ceil( Math.random() * totalCount );
document.getElementById('background-container').style.background = 'images/'+num+'.jpg';
}
</script>
</head>
<body onload='ChangeIt()'>
</body>
</html>