var t = n = 0, count; $(document).ready(function(){ count=$("#banner_list a").length; $("#banner_list a:not(:first-child)").hide(); $("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt')); $("#banner_info").mouseover(function(){window.open($("#banner_list a:first-child").attr('href'), "_blank")}); $("#banner li").mouseover(function() { var i = $(this).text() - 1;//获取li元素内的值,即1,2,3,4 n = i; if (i >= count) return; $("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt')); $("#banner_info").unbind().mouseover(function(){window.open($("#banner_list a").eq(i).attr('href'), "_blank")}) $("#banner_list a").filter(":visible").fadeout(500).parent().children().eq(i).fadein(1000); document.getelementbyid("banner").style.background=""; $(this).toggleclass("on"); $(this).siblings().removeattr("class"); }); t = setinterval("showauto()", 4000); $("#banner").hover(function(){clearinterval(t)}, function(){t = setinterval("showauto()", 4000);}); }) function showauto() { n = n >=(count - 1) ? 0 : ++n; $("#banner li").eq(n).trigger('mouseover'); }