Image Sharing Technique - Instead

I use this code below to replace the image on hover:

$(function() {
    $("#compost").hover(function() {
        origImage=$(this).attr("src");
        $(this).attr("src", "images/order-compost-over.gif")
    },function() {
        $(this).attr("src", origImage)
    });
}); 

I am trying to use fadeIn instead of swap. I tried to work, but no luck. I tried using img tag fadeIn but it did not work.

+3
source share
2 answers

Check out ImageSwitch . Does everything you need, and a little more.

+5
source

If you try to β€œmerge” two images, you will not be able to use standard methods.

Instead, you should:

  • Create a new IMG object
  • A position that is absolutely compared to the previous image
  • Set the new src image to the old one and set its opacity to 1.
  • src URL- 0.
  • ,
  • , .

, :)

+3

Source: https://habr.com/ru/post/1706774/


All Articles