0

On Hover I'm trying to add a class and to change image but my image still stay still on hover. fiddle

  $( "img.animation" ).hover(
  function() {
    $( this )
      .attr('src', "https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/placeholder_logo_2.png")
      .addClass("animated fadeInDown");
    }, function() {
    $( this )
      .attr('src', "https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/placeholder_logo_1.png")
      .removeClass("animated fadeInDown").animate("slow");
    }
);
1
  • 2
    You have image_animation in the class for your images; I assume you meant that the _ to be a space? img.animation != img.image_animation. Commented Aug 16, 2014 at 21:00

2 Answers 2

1

You don't have any img.animation

It looks great this way:

$(document).ready(function(){
//http://api.jquery.com/hover/

    //changing logo
  $( ".grid-item" ).hover(
  function() {
    $( this )
      .find('img')
      .attr('src', "https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/placeholder_logo_2.png")
      .addClass("animated fadeInDown");
    }, function() {
        //than slide it up
    $( this )
      .find('img')
      .attr('src', "https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/placeholder_logo_1.png")
      .removeClass("animated fadeInDown")
      .animate("slow");
    }
);

});//docu.ready
Sign up to request clarification or add additional context in comments.

Comments

1

Change:

img.animation

To:

image_animation

You don't have any class named img.animation.

JSFiddle Demo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.