1
我已经成立了一个示例页面,使这个肩脚本工作: http://twohatsconsulting.com/rotator/在JQuery中1.11.0旋转内容 - 所有div出现在刷新
唯一的问题是,页面刷新,所有三个时的DIV在按照预期淡入第一个DIV之前出现。
我的HTML代码:
<div class="parent">
<div class="child">
first
</div>
<div class="child">
second
</div>
<div class="child">
third
</div>
<div>
我的jQuery代码:
var currentItem = -1;
var direction = 1;
$(document).ready(function(){
switchItem();
setInterval(switchItem, 5000);
});
function switchItem(){
currentItem = (currentItem+1) % ($(".parent .child").size());
// hide the visible one.
$(".parent .child:visible").fadeOut(500, function() {
//now that the hide is done, show the current one.
$(".parent .child").eq(currentItem).fadeIn(500);
});
}
设置CSS子元素例如'.child {display:none; }' – mdesdev
我试过了,但结果是什么都没有出现。 – Melodist