Css 如何根据盒子的背景调整此代码?

Css 如何根据盒子的背景调整此代码?,css,Css,一个名为“sopanha”的StackOverflow用户说,这可以用来在页面上更改背景。如何对其进行调整以应用于长方体的背景 多谢各位 <html> <head> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).ready(function(){ var header = $('body'); var b

一个名为“sopanha”的StackOverflow用户说,这可以用来在页面上更改背景。如何对其进行调整以应用于长方体的背景

多谢各位

<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function(){
var header = $('body');

var backgrounds = new Array(
    'url(http://placekitten.com/100)'
  , 'url(http://placekitten.com/200)'
  , 'url(http://placekitten.com/300)'
  , 'url(http://placekitten.com/400)'
);

var current = 0;

function nextBackground() {
    current++;
    current = current % backgrounds.length;
    header.css('background-image', backgrounds[current]);
}
setInterval(nextBackground, 1000);

header.css('background-image', backgrounds[0]);
});
</script>
</head>
<body>
<header></header>
</body>
</html>

$(文档).ready(函数(){
变量头=$('body');
var backgrounds=新数组(
'网址(http://placekitten.com/100)'
,'网址(http://placekitten.com/200)'
,'网址(http://placekitten.com/300)'
,'网址(http://placekitten.com/400)'
);
无功电流=0;
函数nextBackground(){
电流++;
当前=当前的%1.2.1长度;
css('background-image',backgrounds[current]);
}
设置间隔(下一个背景,1000);
css('background-image',backgrounds[0]);
});

您必须用方框替换此行:

var header = $('body');
body是指HTML中的标记。您可以将其替换为您的所有框(读取:
),也可以使用前面的标签替换特定的框id

var header = $('#id_of_my_box');
对应的HTML代码

<div id="id_of_my_box">My background changes</div>
我的背景更改

在CSS代码“id\u of\u my\u box”中,我将如何称呼“background”?