$(function(){ var imgNode = $("#items").find("img"); $(imgNode).each(function(){ $(this).css({ position:"absolute", left:0, top:0 }); }); $(imgNode).eq(0).css({"z-index":1}); var t = null; var index = 0; t = setInterval(function(){ index = parseInt(index + 1) === $(imgNode).length ? 0 : parseInt(index + 1); change(index,imgNode); },5000); function change(index,changeObj){ $(changeObj).eq(index).siblings().css("z-index","0").fadeOut("slow"); $(changeObj).eq(index).css("z-index","1").fadeIn("slow"); }; var tabs = $("#tab_cards").find("li"); $(tabs).each(function(index){ $(this).mouseover(function(){ $(this).removeClass("tab_on") .addClass("tab_on") .siblings() .removeClass("tab_on"); $("#tab_con").find("ul").eq(index) .show() .siblings() .hide(); $("#tab_more").attr("href",$(this).attr("rel")); }); }); var dateTarget = $("#cur_date"); var tUpdate = null; updateTime(dateTarget); tUpdate = setInterval(function(){ updateTime(dateTarget); },1000); function updateTime(obj){ var weekDay = ["日","一","二","三","四","五","六"]; var curDate = new Date(); $(obj).text("日期:" + curDate.getFullYear() + "-" + toDouble(parseInt(curDate.getMonth() + 1) + "-" + toDouble(curDate.getDate())) + " 星期" + weekDay[curDate.getDay()] + " " + toDouble(curDate.getHours()) + ":" + toDouble(curDate.getMinutes()) + ":" + toDouble(curDate.getSeconds())); } function toDouble(obj){ if(obj < 10){ return "0" + obj; }else{ return obj; } } });