Javascript 淡出动画功能(无 jQuery)
所以我做了这个函数并且它起作用了:
var opacity = 9;
function func() {
$("action").style.opacity = "0." + opacity;
opacity--;
if (opacity == -1) { window.clearInterval(fading); }
}
var fading = window.setInterval("func()", 200);
但这实际上并不是一个单一的函数。 所以我这样做了:
function fadeOut(ms) {
var opacity = 9;
function func() {
$("action").style.opacity = "0." + opacity;
opacity--;
if (opacity == -1) { window.clearInterval(fading); }
}
var fading = window.setInterval("func()", ms);
}
fadeOut(200);
突然 func() 未定义。 帮助 ? :|
So I made this function and it works:
var opacity = 9;
function func() {
$("action").style.opacity = "0." + opacity;
opacity--;
if (opacity == -1) { window.clearInterval(fading); }
}
var fading = window.setInterval("func()", 200);
But thats acutally not really one single function.
So I did this:
function fadeOut(ms) {
var opacity = 9;
function func() {
$("action").style.opacity = "0." + opacity;
opacity--;
if (opacity == -1) { window.clearInterval(fading); }
}
var fading = window.setInterval("func()", ms);
}
fadeOut(200);
And suddenly func() is undefined.
Help ? :|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改:
to
我不确定
$("action")
返回什么,如果它的 jQuery 则样式不是 $("action") 的有效成员。Change:
to
Am not sure what
$("action")
return though, if its jQuery then style is not a valid member of $("action").