jQuery Change Image src with Fade Effect

后端 未结 4 446
旧时难觅i
旧时难觅i 2020-12-04 22:04

I\'m trying to create an effect where you click on a thumbnail image, and the link to the thumbnail will replace the main image, but fade it in. This is the code I\'m curren

4条回答
  •  甜味超标
    2020-12-04 22:29

    I thing instead of using FadeIn and fadeOut, its better to use fadeTo functionality as fadeIn and fadeOut created a time gap between them for few micro-seconds.

    I have used above code from Sylvain : thanks to him

    $("#link").click(function() {
    
      $("#image").fadeTo(1000,0.30, function() {
          $("#image").attr("src",$("#link").attr("href"));
      }).fadeTo(500,1);
      return false;
    });
    

提交回复
热议问题