jquery - fadeIn 效果只闪烁

标签 jquery css fadein

我正在尝试向我的 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')

JSFidde DEMO

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/

相关文章:

jquery - swipeUp 或 swipeDown 在模拟移动平台的 google chrome 中无效

javascript - 如何在div中存储下拉选择的值

javascript - 如何使用 fadeIn with display=inline-block

javascript - 在 jQuery 滚动条上淡入淡出 div

javascript - 设置按钮按下功能以触发带有 Id 的 Ajax 调用

javascript - HTML5 日期时间组件在浏览器中不起作用

javascript - 顶级属性在动画功能中不起作用

jquery - 为什么我使用这个 Masonry 示例代码在我的 div 之间有空格?

html - 导航栏间距中的排序列表

javascript - 单击输入字段时会出现“保存”按钮