為什么我的透明度沒有顯示呢
window.onload=function(){
?? var div=document.getElementById("div1");
?? div.onmouseover=function(){
? ? ? ?play(10,100);
? ?}
?? div.onmouseout=function(){
? ? ? ?play(-10,30);
? ?}
}
var timer=null;
var alpha=30;
function play(speed,target){
? ?clearInterval(timer);
? ?var div=document.getElementById("div1");
? ?timer=setInterval(function(){
? ? ? ?var speed=speed;
? ? ? ?if(alpha==target){
? ? ? ? ? ?clearInterval(timer);
? ? ? ?}else{
? ? ? ? ? ?alpha+=speed;
? ? ? ? ? ?div.style.filter='alpha(opacity:'+alpha+')';
? ? ? ? ? ?div.style.opacity=alpha/100;
? ? ? ?}
? ?},30);
}
2016-08-16
var speed=speed; 我不是很明白你為什么要這樣定義一個變量。
2016-08-11
?var speed=speed;這行注釋掉,你傳參這個函數(shù)里已經(jīng)有一個叫speed的變量了,重復(fù)定義了
2016-08-11
/* var speed=speed;*/
我把這句話注釋掉就可以了 可是不是很明白是為什么 希望大神點播