【问题标题】:Why isn't this jQuery working? Image fadeIn and fadeOut为什么这个 jQuery 不起作用?图像淡入淡出
【发布时间】:2014-05-17 07:44:31
【问题描述】:

我的 css 中有一个 photoshow 类。它们是图像。我希望它们在页面加载时淡出并淡入。任何 wysihtml5 的第一行工作正常。有什么想法吗?

控制台错误:

event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

s

$(document).ready(function(){

  $('.wysihtml5').each(function(i, elem) {
    $(elem).wysihtml5();
  });


  $('.photoshow').fadeOut().fadeIn('slow');

})

这是 HTML

<%= link_to 'Back', :back %> <br>
  <%#= @photo.name %>
  <div class="photoshow">
    <%= image_tag @photo.image.url, width: '500', class: 'photoshow' %>
  </div>

【问题讨论】:

  • 应该可以正常工作 -> jsfiddle.net/adeneo/zD7t5
  • 有趣。我不知道这里发生了什么。 :(
  • 打开控制台 (F12) 并检查错误?
  • 刚刚更新了带有错误消息的原始帖子
  • $('.photoshow').fadeOut('slow', function() { $(this).fadeIn('slow'); }) 怎么样? chainig 和使用完整回调有区别吗?

标签: javascript jquery css ruby-on-rails


【解决方案1】:

您可以尝试类似的方法:-

$(document).ready(function() {
    // Hides the picture so no one can see it
    $('.photoshow').hide(0);

    $('.wysihtml5').each(function(i, elem) {
        $(elem).wysihtml5();
    });

    // Fades the picture in
    $('.photoshow').fadeIn('slow');
});

【讨论】:

  • 这没有效果。发生了其他事情。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-06
  • 1970-01-01
  • 2018-09-03
  • 2014-08-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多