我正在创建一个网站,可以在主页上展示多张图片,并且可以通过按钮点击循环显示。就像一个画廊,但更适合页面预览。我想要解决的问题是如何在单击按钮时更改div的id/class。
我查看了一些其他问题,但没有一个问题显示这种情况发生在4个不同的ids上。
我非常新于JavaScript,并试图找出最适合我的情况的方法。
这是我为我的页面制作的jsFiddle。目标是使顶部的按钮在单击时将绿色div #Filler
更改为新的id/class。
#Filler {
margin: auto;
max-height: 700px;
width: 1400px;
background-color: green;
max-width: 1366px;
height: 800px;
z-index: 1;
margin-top: -250px;
overflow: inherit;
background-image: url(nature5.jpg);
animation: Filler 1s 1;
-webkit-animation: Filler 1s 1;
transition-timing-function: ease;
-webkit-transition-timing-function: ease;
opacity:1; }
更改为
#Filler2 {
margin: auto;
max-height: 700px;
width: 1400px;
background-color: red;
max-width: 1366px;
height: 800px;
z-index: 1;
margin-top: -250px;
overflow: inherit;
animation: Filler 1s 1;
-webkit-animation: Filler 1s 1;
transition-timing-function: ease;
-webkit-transition-timing-function: ease;
opacity:1;
}
像我说的那样,我对这个非常陌生,这是一个WebDesign课程项目。