0

Instead of applying individual CSS properties, can I animate to another class? I am avoiding having to retrieve individual class properties and apply them within the .animate() method.

I know you can specify transitions in a CSS class but I am looking for a JQuery solution otherwise I could have toggled between classes.

The question marked as a duplicate does not provide the answer I am after, the answers given either suggest the use of CSS transitions or switching and toggling between classes which does not solve my problem as what I am trying to do is to animate to a class that is already assigned to an element.

The element has a class that specifies the width and height of the element, at somepoint (mouse over) those element properties may change, at another point (mouse) leave I want to bring the element back to it's original size.

Abs
  • 165
  • 1
  • 14
  • 2
    Possible duplicate of [animating addClass/removeClass with jquery](https://stackoverflow.com/questions/7302824/animating-addclass-removeclass-with-jquery) – Neil Oct 06 '17 at 13:47

1 Answers1

0

You can chose the target where you want to animate to

var target = $(document).find('.yourclass').offset().top
$('body,html').animate({
   scrollTop: target
}, 500);

with offset().top you get the position of your searched classes container in relation to the document.

I hope to have answered your question.

Doml The-Bread
  • 1,761
  • 1
  • 11
  • 17