$(function(){ var t = n = 0, count = $("#playShow a").size();//得到a标签的总数 $("#playShow a:not(:first-child)").hide();//除了第一个全部隐藏 $("#playText").html($("#playShow a:first-child").find("img").attr('alt'));//给第一个下部文字找到数据 $("#playNum a:first").css({"background":"#cc0000",'color':'#fff'});//将第一个数字标签变为红色 $("#playText").click(function(){window.open($("#playShow a:first-child").attr('href'), "_blank")});//给第一个下部文字找到链接 $("#playNum a").click(function() { var i = $(this).text() - 1; n = i; if (i >= count) return; $("#playText").html($("#playShow a").eq(i).find("img").attr('alt')); $("#playText").unbind().click(function(){window.open($("#playShow a").eq(i).attr('href'), "_blank")}) $("#playShow a").filter(":visible").hide().parent().children().eq(i).fadeIn(100); $(this).css({"background":"#cc0000",'color':'#fff'}).siblings().css({"background":"#000",'color':'#fff'}); }); t = setInterval(showAuto, 5000); $("#play").hover(function(){clearInterval(t)}, function(){t = setInterval(showAuto, 5000);}); function showAuto() { n = n >= (count - 1) ? 0 : ++n; $("#playNum a").eq(n).trigger('click'); $("#playNum a").eq(n).trigger('click').fadeIn('slow'); } });