css代碼
<style>
.jfocus{width:300px;height:300px;border:#ccc 1px solid;background-color:#fff;}#jfocuspic{filter: progid:dximagetransform.microsoft.fade (duration=0.5,overlap=1.0 );width:300px;height:200px;overflow:hidden;}#jfocuspic a{display:none; font-size:2em; text-align:center; line-height:200px; font-weight:bold; background-color:#ccc; height:200px; cursor:pointer;}#jfocusnum li{cursor:pointer;height:50px; width:50px; line-height:50px;display:inline-block; color:#000; border:#999 1px solid; text-align:center; background-color:#ccc; float:left; margin:0 5px;}#jfocusnum li.on{color:#f00; font-weight:bold; border:#900 1px solid; font-size:14px;}
</style>
網頁特效代碼
<script>
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].onmouseo教程ver=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();
}
</script>
html代碼
<div class="jfocus">
<div id="jfocuspic">
<a href="#" style="display:block;">圖片一</a>
<a href="#">圖片二</a>
<a href="#">圖片三</a>
<a href="#">圖片四</a>
</div>
<ul id="jfocusnum">
<li class="on">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>