2
我通过一系列HTML元素的条件上点击鼠标即事件序列要循环是:里面的div 2.点击的div 3.显示下一个元素 4.点击 5.显示器上 1显示元件下一个元素 ....等从最终元件背面 6.循环到第一元件为什么不通过HTML元素循环jQuery脚本?
我已经创建了下面的代码,但下一个元素例如ID =“图像”不替换当前元素。这是为什么?请参阅下面的HTML,CSS和JS。
<div class="frame" id="title">CULTURAL</div>
<div class="frame" id="image">
<img class="topLeft" src="images/zanzibar_market_1.jpg" alt="Zanzibar Cloth">
</div>
<div class="frame" id="text">A culture encompasses the ideas, customs, and social behaviour of a people or society.
When we mix with other cultures we are enriched by the experience. We know more of the world.</div>
.frame {
margin: auto;
width: 300px;
height: 300px;
border: 1px solid skyblue;
}
#title {
font-size: 2em;
opacity: 1.0;
}
#image {
opacity: 0.0;
}
#text {
opacity: 0.0;
}
var frames = document.getElementsByClassName("frame");
for(var i=0; i<frames.length; i++){
$("frames".eq(i)).click (function() {
$("frames".eq(i)).animate({
opacity: 0.0
});
var x = i + 1;
$("frames".eq(x)).animate({
opacity: 1.0
});
});
};
它实际上是'.frame',不'frames'。 – Ionut
@Ionut,谢谢! – Shomz
我现在有:var frames = document.getElementsByClassName(“frame”);对于(var i = 0; i
Trevor