效果类似这种,自动播放,实质控制层的显示隐藏。需要的朋友可以参考下。
效果图:
实现代码:
复制代码 代码如下:
<html>
<head>
<title>Jquery 自动轮播效果</title>
<script src="https://www.jb51.net/js/jquery-1.6.2.min.js" type="text/javascript"></script>
<style>
.spanhide{display: none;}
#top a:hover{color: red;}
</style>
</head>
<body>
<div id = "main">
<div id = "top">
<a href="javascript:void(0)">1</a>
<a href="javascript:void(0)">2</a>
<a href="javascript:void(0)">3</a>
<a href="javascript:void(0)">4</a>
<a href="javascript:void(0)">5</a>
</div>
<div id = "tbody">
<span> <img src="https://www.jb51.net/images/24877.jpg" /> </span>
<span> <img src="https://www.jb51.net/images/74389.gif" /> </span>
<span> <img src="https://www.jb51.net/images/77904.jpg" /> </span>
<span> <img src="https://www.jb51.net/images/81177.jpg" /> </span>
<span> <img src="https://www.jb51.net/images/93144.jpg" /> </span>
</div>
</div>
</body>
<script type="text/javascript">
$(function(){
var i = 0;
var f = 0;
var t;
var tops = $("#top a");
var tl = tops.length;
var bodys = $("#tbody span");
tops.mouseover(function(){
i = $.inArray(this,tops);
bodys.hide().eq(i).show();
i++;
i = i>=tl?0:i;
if (f == 1) {
t = setTimeout(mmover,2000);
}
else{
stop();
}
f = 0;
});
bodys.mouseover(function(){
stop();
});
bodys.mouseout(function(){
t = setTimeout(mmover,2000);
});
tops.mouseout(function(){
t = setTimeout(mmover,2000);
});
mmover();
function stop(){
clearTimeout(t);
}
function mmover(){
f = 1;
tops.eq(i).mouseover();
}
});
</script>
</html>
您可能感兴趣的文章: