Jquery 一个css中for循环生成的页面的不同背景
对于每个页面,我都需要使用不同的背景图像,其ID由以下for循环语句生成:Jquery 一个css中for循环生成的页面的不同背景,jquery,html,css,Jquery,Html,Css,对于每个页面,我都需要使用不同的背景图像,其ID由以下for循环语句生成: `$`function nextButton() { if(curNum<numScreens) { curNum = parseInt(curNum)+1; document.location.href = '#'+curNum; $( init ); } } 但它不起作用。 你能帮帮我吗 只需将body.1、body.2和body.3分别更改为: body #
`$`function nextButton() {
if(curNum<numScreens) {
curNum = parseInt(curNum)+1;
document.location.href = '#'+curNum;
$( init );
}
}
但它不起作用。
你能帮帮我吗 只需将body.1、body.2和body.3分别更改为:
body #body_1 {...}
body #body_2 {...}
body #body_3 {...}
这可能是一个输入错误,但在html中,主体有一个
id
,在css中,您通过class
(
选择器)访问它。此外,类和id不能以数字开头。试着用“#body-1”或其他什么来引导。我确认@Torr3nt是正确的,不能用数字引导类或ID。
body.1 { background-image: url("bg.gif");
background-repeat: no-repeat;
background-attachment: scroll;
background-position: 53% 10%;
z-index: 1;
}
body.2 { background-image: url("bg1.gif");
background-repeat: no-repeat;
background-attachment: scroll;
background-position: 53% 10%;
z-index: 1;}
body.3 { background-image: url("bg2.gif");
background-repeat: no-repeat;
background-attachment: scroll;
background-position: 53% 10%;
z-index:1 }
body #body_1 {...}
body #body_2 {...}
body #body_3 {...}