======================================
html部分
======================================
<div id="picslide">
<ul id="picslidelist">
<li class="picfirst"><a href="#" target="_blank"><img width="800" height="300" alt="" src="#"></a>
<div class="picslidedetail">
<h3>标题一</h3>
<p>描述文本</p>
</div>
</li>
<li class="picfirst"><a href="#" target="_blank"><img width="800" height="300" alt="" src="#"></a>
<div class="picslidedetail">
<h3>标题二</h3>
<p>描述文本</p>
</div>
</li>
<li class="picfirst"><a href="#" target="_blank"><img width="800" height="300" alt="" src="#"></a>
<div class="picslidedetail">
<h3>标题三</h3>
<p>描述文本</p>
</div>
</li>
<li class="picfirst"><a href="#" target="_blank"><img width="800" height="300" alt="" src="#"></a>
<div class="picslidedetail">
<h3>标题四</h3>
<p>描述文本</p>
</div>
</li>
</ul>
<div id="picslideNav">
<ul class="clearfix">
<li class="picslideprev">上一个</li>
<li class="trigger"><a href="javascript:void(0)"><img width="58" height="58" src="#"></a></li>
<li class="trigger"><a href="javascript:void(0)"><img width="58" height="58" src="#"></a></li>
<li class="trigger"><a href="javascript:void(0)"><img width="58" height="58" src="#"></a></li>
<li class="trigger"><a href="javascript:void(0)"><img width="58" height="58" src="#"></a></li>
<li class="picslidenext">下一个</li>
</ul>
</div>
<div id="picslidebg"></div>
</div>
======================================
js部分
======================================
<script type="text/javascript">
//首页焦点图
$(function(){
(function(){
var curr = 0;
$("#picslideNav .trigger").each(function(i){
$(this).click(function(){
curr = i;
$("#picslidelist li").eq(i).fadeIn("slow").siblings("li").hide();
$(this).siblings(".trigger").removeClass("imgSelected").end().addClass("imgSelected");
return false;
});
});
var pg = function(flag){
//flag:true表示前翻, false表示后翻
if (flag) {
if (curr == 0) {
todo = 4;
} else {
todo = (curr - 1) % 5;
}
} else {
todo = (curr + 1) % 5;
}
$("#picslideNav .trigger").eq(todo).click();
};
//前翻
$(".picslideprev").click(function(){
pg(true);
return false;
});
//后翻
$(".picslidenext").click(function(){
pg(false);
return false;
});
//自动翻
var timer = setInterval(function(){
todo = (curr + 1) % 5;
$("#picslideNav .trigger").eq(todo).click();
},5000);
//鼠标悬停在触发器上时停止自动翻
$("#picslide").hover(function(){
clearInterval(timer);
},
function(){
timer = setInterval(function(){
todo = (curr + 1) % 5;
$("#picslideNav .trigger").eq(todo).click();
},5000);
}
);
})();
});
</script>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。