Javascript在函数中设置不透明度
Javascript setting opacity in function
function fade(obj, time) {
if(this) { //prevents the function from being called too many times at once
addCallData(this);
}
if(!obj || !time) {
alert("Object/time parameters are required.'n");
return false;
} else {
if(!func_data[this]["fade"]) { /*if fade is not defined for [this], then define it*/
func_data[this]["fade"] = ((obj.style.opacity)?1:(obj.style.filter));
} else {
if(func_data[this]["fade"] <= 0) { /*if object opacity has declined completely, then hide/remove the element to indicate that the object has faded*/
obj.style.display="none";
return false;
}
func_data[this]["fade"]=((func_data[this]["fade"])--); /*gradually reduce fade*/
((obj.style.filter)?((obj.style.filter)=func_data[this]["fade"]):
(obj.style.filter("alpha(opacity="+(func_data[this]["fade"])+""))); /*ultimately, set opacity to x-0.1 or x-1*/
setTimeout(function(){fade(obj, time);}, time); /*loop until false occurs*/
}
}
}
我不完全确定为什么这不起作用。我可以将func_data[this]["fade"]
设置为0.50,HTML元素将失去50%的不透明度,但如果我将该属性的值设置为不透明度,函数将停止在那里,不会达到超时阶段。
检查这个:
<>之前setOpacity(value) {testObj.style.opacity = value/10;testObj.style.filter =' alpha(不透明度=' + value*10 + ')';}之前来源:http://www.quirksmode.org/js/opacity.html
相关文章:
- 设置1400个Raphael.js对象的不透明度动画会影响动画性能
- 使用媒体查询设置背景图像的不透明度
- 拖动时设置滚动条不透明度
- Three.js设置对象不透明度/透明度
- Highcharts设置背景颜色和不透明度
- 加载页面时,将“不透明度”设置为 0 到 1
- 在高图表折线图中设置折线不透明度
- kineticJS按顺序加载图像(并设置fillPatternImg)不透明度补间不起作用
- 使用javascript设置按钮的不透明度值
- 如果我通过javascript设置不透明度,CSS悬停事件将被取消
- 如何使用javascript和css为select中的选项设置不透明度
- 通过使用Javascript设置不透明度来淡入元素
- 在IE 8中使用javascript设置不透明度
- 使用js设置不透明度或关闭模态窗口
- 开始0透明度和onClick设置不透明度为100
- Javascript在函数中设置不透明度
- 设置不透明度与范围滑块
- Chrome设置不透明度是不一致的渲染如预期
- 设置不透明度为LayerGroup和Slider
- 为什么javascript中没有设置不透明度