【问题标题】:Jquery image rollover - slide transitionjQuery图像翻转 - 幻灯片过渡
【发布时间】:2013-04-13 04:13:41
【问题描述】:

如何使用 Jquery 更改悬停时的图像并带有上滑过渡?我在互联网上搜索过,但找不到有效的代码。我发现的所有代码都使用淡入或淡出。非常感谢!

这是我找到的代码,但它使用淡入淡出:

<script>
$(function() {
$('.change').mouseenter(function(){
  $(this).slideUp('fast', function(){
    $(this).attr('src', $(this).data('on'));
    $(this).fadeIn();
  });
});

$('.change').mouseleave(function(){
  $(this).slideUp('fast', function(){
    $(this).attr('src', $(this).data('off'));
    $(this).fadeIn();
  });
});
});</script>

和html:

<img class="change" src="images/portofoliu/next.gif" data-on="images/portofoliu/prev.gif" data-off="images/portofoliu/next.gif">

【问题讨论】:

  • 所有动画都可以使用 CSS3
  • 是的,我知道 CSS 3 是一个不错的选择,但是 IE 不喜欢 CSS3...

标签: javascript jquery html image transition


【解决方案1】:
<div id="clickme">
  Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123" />

$('#clickme').hover(function() {
  $('#book').slideUp('slow', function() {
    // Animation complete.
  });
});

http://jsfiddle.net/GFdW5/3/

http://api.jquery.com/slideUp/

编辑:最终解决方案:http://jsfiddle.net/hellomynameisluc/frTFw

【讨论】:

  • 谢谢!不幸的是,这段代码似乎对我不起作用……我做错了什么?
  • 你的 jquery 版本是最新的吗?
  • 好的,我发现了错误!有一个复制错误:)。现在可以了,谢谢,但它只能向上滑动图像,我想通过向上滑动来更改图像。对不起我的英语......
  • 哦,我明白了。这涉及更多一点。给我一点时间找点东西。
  • 没问题。快乐编码! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-23
  • 1970-01-01
  • 2011-08-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-18
相关资源
最近更新 更多