我正在尝试向我的 jquery 字符串添加淡入淡出,以便在单击时 div 淡入。我只是得到一个闪光,然后没有褪色。我仍然是 jquery 的初学者。这看起来应该有效吗?
$(document).ready(function() {
$("#Thumb1").click(function() {
$("#hidden").html('<iframe src="http://player.vimeo.com/video/38366163" width="508" height="286" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>').hide().fadeIn('2000');
$("#leftsidePlayer").text("hey there new text!");
});
});
我也尝试过使用 .hide
并在我的 CSS 中使用 disply: none
具有相同的效果。
最佳答案
持续时间应该是数字而不是字符串:
$("#hidden").hide()
.html('<iframe src="http://player.vimeo.com/video/38366163" width="508" height="286" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>')
.fadeIn(2000); // <==== Not fadeIn('2000')
Durations are given in milliseconds; higher values indicate slower animations, not faster ones. The strings 'fast' and 'slow' can be supplied to indicate durations of 200 and 600 milliseconds, respectively. If any other string is supplied, or if the duration parameter is omitted, the default duration of 400 milliseconds is used.
旁注,隐藏元素然后将其附加到 <iframe>
会更好完成所有这些后,淡入容器。
关于jquery - fadeIn 效果只闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9705757/