$(function(){ var imgfuntion = function(imgparent,navblock){ var im = 0, text = "", maxsize = $(imgparent).find("img").length; // $(imgparent).find("img").each(function(j){ // var sss = $(imgparent).find("img").eq(j).attr('src'); // $(imgparent).find("li").eq(j).css({'background':'url('+ sss +')'+' no-repeat center','background-size':'cover'}); // $(imgparent).find("img").eq(j).hide(); // }) for(var i=maxsize;i>0;i--){ text += ""; } //生成点点并居中 //$(navblock).html(text); var showimg = function(){ // $(imgparent).find("img").eq(im).siblings().stop().animate({opacity:0},500,function(){ // $(this).css({"display":"none"}); // }); $(imgparent).find("li").eq(im).css({"display":"block"}).siblings().hide(); $(navblock).find("span").eq(im).addclass("current").siblings().removeclass("current"); } //初始化 showimg(); $(navblock).find("span").bind("mouseover",function(){ im = $(this).index(); showimg(); }) var setint = setinterval(function(){ im++; im %= maxsize; showimg(); },3500) $(navblock).hover(function(){ clearinterval(setint); },function(){ setint = setinterval(function(){ im++; im %= maxsize; showimg(); },3500) }) } imgfuntion(".home_ulblock",".home_navblock"); $(".home_bigimg").height($(window).height() - 84 - 50); $(window).resize(function(){ $(".home_bigimg").height($(window).height() - 84 - 50); }) })