<分区>
标签 javascript jquery css
<分区>
现在我正在使用 jquery.transit 开发一个幻灯片放映应用程序。我想要做的是在显示动画后隐藏照片。所以我将显示、转换和转换的属性设置为“无”值。然后,幻灯片放映应用程序运行良好,但我注意到 display: none 未在 Chrome 的 js 控制台中设置。经过一些试验,我找到了一种方法来启用 display: none 在我的代码中设置两次。 有谁知道我的代码中有什么问题?也许我的js代码有一些问题。
function showPhoto() {
photo_list[counter]
.css({
scale : 2,
display : 'inline'
})
.transition({
opacity : 1
}, 1000)
.transition({
x : '+=20',
y : '+=30',
scale: 2.3
}, 1500)
.transition({
opacity: 0
}, 500, 'linear', function() {
$(this)
.css({
diaplay : 'none',
transform : 'none',
translate : 'none',
x : 0,
y : 0,
scale : 1
});
$(this).css({display: 'none'}); // it works, but its redundant
incrDomIndex();
showPhoto();
});
};
photo_list 是一个img dom 的Array 对象,每一个在下面都有一个class。
.photo {
position : absolute;
top : 0;
left : 0;
width : 800px;
height : 500px;
}
最佳答案
$(this)
.css({
diaplay : 'none', // Mistake here
transform : 'none',
translate : 'none',
x : 0,
y : 0,
scale : 1
});
$(this).css({display: 'none'}); // it works, but its redundant
incrDomIndex();
showPhoto();
将 diaplay 更改为 display 并查看是否可以为您解决这两个错误。
关于javascript - css 'display none' 第一次不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28689669/