3.js 復制代碼 代碼如下: function $(id,tag){var re=(id&&typeof id!="string")?id:document.getElementById(id);if(!tag){return re;}else{return re.getElementsByTagName(tag);}}//獲取元素對象 function FocusImg(focbox,picobj,numbox,numobj,time){ var n=0; var imglist=$(focbox,picobj); var Num=$(numbox,numobj); function setBg(value){for(var i=0;i<Num.length;i++) Num[i].className=(value==i)?"on":"";}//設置字母列表的樣式切換; function plays(value){ if(document.all) $(focbox).filters[0].Apply();//濾鏡 for(i=0;i<Num.length;i++){i==value?imglist[i].style.display="block":imglist[i].style.display="none";} if(document.all) $(focbox).filters[0].play(); } function mouse(n){//設置鼠標經過和離開後的事件; for(var i=0;i<Num.length;i++){ (function(n){ Num[i].onmouseover=imglist[i].onmouseover=function(){clearInterval(autoStart);Mea(n);} Num[i].onmouseout=imglist[i].onmouseout=function(){setAuto();} })(i); } } function Mea(value){n=value;mouse(n);setBg(value);plays(value);} function auto(){n++;if(n>Num.length-1)n=0; Mea(n);} function setAuto(){autoStart=setInterval(function(){auto();},time)} setAuto(); }