jquery - 文本到图像翻转并淡入/淡出

标签 jquery rollovers

我找到并修改了一种创建文本到图像翻转的好方法,在这里:http://jsfiddle.net/pkZAW/12/

    $( function() {
  $("#imglink").hover(
    function () {
      $(this).attr('small',$(this).html());
      $(this).html($(this).attr('full'));
    },
    function () {
       $(this).html($(this).attr('small'));
    }
  );
});​

但是,我需要淡入淡出的过渡,就像此处缩略图上的那样: http://lydiafraserward.co.uk/index.php?page=producing

经过多次搜索后,我无法将此转换添加到脚本中:-? ..有什么想法吗..?

最佳答案

我认为这种情况不需要 live() 。我不会在 mouseleave 函数上使用淡出,因为动画会叠加。

你也可以尝试这个:

$( function() {
    $("#imglink").hover(
    function () {
        $(this).attr('small',$(this).html());
        $(this).stop(false,true).fadeOut(250,function() {
            $(this).html($(this).attr('full'));
            $(this).stop(false,true).fadeIn(250);
        });
   }, function () {
        $(this).html($(this).attr('small'));

   });
  });

编辑:使用 anchor 标记周围的跨度标记来修复闪烁效果:演示:http://jsfiddle.net/LYjvp/1/

关于jquery - 文本到图像翻转并淡入/淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13400389/

相关文章:

javascript - 翻转从数组中调用图像

html - JSON 作为 Flex 中的 HTML 数据 - 超链接翻转

javascript - 通过 Javascript 迭代复杂 JSON 对象的最简单方法

c# - 从 MVC HttpPost 将错误返回给 jQuery

javascript - Bootstrap 多模态按钮

javascript - Jquery表单提交空值到Mysql

javascript - 如何使用jquery追加功能添加图像的src?

javascript - 链接 JS 翻转图像

javascript - 图片元素 srcset 响应式图像翻转