1

What I would like to do :

Moving 5px down image 2 when hovering image 1:

image1 with its reflection (image2)

I don't know code (a little CSS) but I think this one could help to do what I want, of course it's not working, could you tell me why?

jQuery(document).ready(function($){

$('.image1').on('mouseenter', function() {
$(".image2").addClass("move5px");
});
});

$('.image1').on('mouseleave', function() {
$(".image2").removeClass("move5px");
});

The class I use:

.move5px{
   top:-5px
}
1
  • 1
    Please include the relevant HTML and CSS to provide a working demonstration. Commented Jul 6, 2021 at 23:03

1 Answer 1

0

ok here is the working code (#id names added):

jQuery(document).ready(function($) {
  $('#image1').on('mouseenter', function() {
    $("#image2").addClass("move5px");
  });
  $('#image1').on('mouseleave', function() {
    $("#image2").removeClass("move5px");
  });
});

And the css with a transition added for animation :

#image2 { transition: 150ms; }
.move5px{
   padding-top:5px; 
}
Sign up to request clarification or add additional context in comments.

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.