Wednesday, March 25, 2015

jQuery Change Image src with Fade Effect

I think 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

Use fadeTo():

$("#link").click(function() {

  $("#image").fadeTo(1000,0.30, function() {
  return false;

Use fadeIn and fadeOut:

$(".thumbs a").click(function(e) {
    $imgURL = $(this).attr("href");
    $(".boat_listing .mainGallery")
        .fadeOut(400, function() {
            $(".boat_listing .mainGallery").attr('src',$imgURL);

No comments: