我想创建经过动作悬停带来的彩色图像,也曾经悬停被删除它消失恢复到原来的图像。

我把它练到与帮助粉化工业和布拉德在这个论坛的第一个图像中的衰落,但是我需要得到它,所以它淡出,一旦你悬停偏了点。

目前它淡出图像不了了之,然后消失在新的。于是,这将留在地方,无论我是否悬停关闭或没有。

像它

ID,因此它似乎是彩色图像通过黑白一个衰落衰落在...以及一旦悬停被移除之前回复到并列衰落为0。

任何帮助,将不胜感激。

//Loop through the images and print them to the page
   for (var i=0; i < totalBoxes; i++){
    $.ajax({
     url: "random.php?no=",
     cache: false,
     success: function(html) {
      // following line I originally suggested, but let's make it better...
      //$('#bg').append(html).fadeIn('slow');
      // also note the fine difference between append and appendTo.
      var $d = $(html).hide().appendTo('#bg').fadeIn('slow');
      $('img', $d).hover(function() {
       var largePath = $(this).attr("rel");
       $(this).fadeOut("slow", function() {
        $(this).attr({ src: largePath }).fadeIn("slow");
       });
      });
     }
    });
   }
有帮助吗?

解决方案

您悬停只有一个鼠标悬停功能 - 做鼠标移开时...

的东西
$('img', $d).hover(function() {
    //This is the mouseover function
    var largePath = $(this).attr("rel");
    $(this).fadeOut("slow", function() {
        $(this).attr({ src: largePath }).fadeIn("slow");
    }
    );
},
function() {
    //This is the mouseout function!  Do something here!
});

其他提示

我真的不知道jQuery的,但如果是我一直在使用和听起来像你可能是什么之后,下面的代码。我用它来与子画面图像停止出现在某些浏览器的恼人的闪烁。

$(function() {
    $(".fadebtn")
    .find("span")
    .hide()
    .end()
    .hover(function() {
            $(this).stop(true, true).find("span").fadeIn(600);
    }, function() {
            $(this).stop(true, true).find("span").fadeOut(200);
    });
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top