87,910
社区成员
发帖
与我相关
我的任务
分享
<script>
$(function() {
var index = 0, time0 = 0;
function start(){
time0 = setInterval(function() {
show(index);
index++;
if (index == 3) {
index = 0;
}
}, 3000);
}
function stop(){
clearInterval(time0);
}
function show(index) {
$(".d_d").eq(index).show().siblings().hide();
$(".d_s span").eq(index).css("background-color", "#99c").siblings().css("background-color", "#936");
}
$(".d_s span").click(function(e) {
stop();
var $index1 = $(this).index();
if(index != $index1){
index = $index1;
show(index);
}
start();
});
start();
})
</script>
<style>
.d_d{ position:relative; float:left; width:100px; }
.d_s span{ font-size:18px; width:40px; height:40px; background-color:#936; margin-right:10px; color:#fff;}
.d_s span:hover{ background-color:#99C; color:#fff;}
</style>
<div>
<div class="d_d">
a
</div>
<div class="d_d" style="display:none;">
b
</div>
<div class="d_d" style="display:none;">
c
</div>
</div>
<div class="d_s">
<span style="background-color:#99c;">
1
</span>
<span>
2
</span>
<span>
3
</span>
</div>