123456789101112131415161718192021222324252627282930313233 |
- $(function(){
- var bWidth = $("#list_focus").width();
- var picNumber = $("#list_focus .img_list li").length;
- var index = 1;
- var picTimer;
- $("#list_focus .img_list").css("width",bWidth*picNumber);
- var btn = "<ul class='btn'>";
- for(var i=0; i < picNumber; i++) {
- btn += "<li></li>";
- }
- btn += "</ul>";
- $("#list_focus").append(btn);
- $("#list_focus .btn li").mouseenter(function() {
- index = $("#list_focus .btn li").index(this);
- showPics(index);
- }).eq(0).addClass("active");
- $("#list_focus").hover(function() {
- clearInterval(picTimer);
- $("#list_focus .btn").animate({"bottom":8,"opacity":1},180);
- },function() {
- $("#list_focus .btn").animate({"bottom":-10,"opacity":0},180);
- picTimer = setInterval(function() {
- showPics(index);
- index++;
- if(index == picNumber) {index = 0;}
- },4000);
- }).trigger("mouseleave");
- function showPics(index){
- var rollLeft = -index*bWidth;
- $("#list_focus .img_list").stop(true,false).animate({"left":rollLeft},300);
- $("#list_focus .btn li").removeClass("active").eq(index).addClass("active");
- };
- });
|