문제

나는 컬러 이미지를 가져 오는 동작을 만들려고 노력하고 있으며 일단 호버가 제거되면 원래 이미지로 다시 사라집니다.

나는이 포럼에서 Funka와 Brad를 Help Funka와 Brad와 함께 첫 번째 이미지에서 페이딩하는 지점까지 가져 왔지만, 일단 떠 다니면 사라져야합니다.

현재 그것은 이미지를 아무것도 퇴색시키고 새로운 것을 사라지는 다음 이미지를 사라집니다. 이것은 내가 떠나는 지 여부에 관계없이 제자리에 머무를 것입니다.

ID와 같은 경우 색상 이미지가 흑백 이미지를 통해 페이딩되는 것처럼 보입니다.

모든 도움이 감사하겠습니다.

//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