A better implementation of a fading image swap with javascript / jQuery

前端 未结 3 1888
一个人的身影
一个人的身影 2021-01-20 07:26

This is less of a specific problem or error but more of a implementation question.

First of I\'d like to say that I\'ve been through a lot of fading image tutorials

3条回答
  •  星月不相逢
    2021-01-20 07:43

    try to do it easy like this:

     $('#img').hover(
         function() {
           $(this).stop().fadeIn(...).attr('src', 'image_o').fadeOut(...)
         }, 
         function() {
           $(this).stop().fadeIn(...).attr('src', 'image').fadeOut(...)
     });
    

提交回复
热议问题