How to apply a function to a specific element?

I have js (jquery) function:
$(function animate() {
tl.fromTo('item name', 0.4, { y: 50, opacity: 0 }, { y: 0, opacity: 1, ease: Power4.easeOut });
});

I want to make a function called by that element to which I want. Something like this:
$('.heading').animate();

I want to shorten the code below a hundred times not to write which element I want to animate.
And if I want a lot of elements to animate, we'll get this mess:
tl.fromTo('.heading', 0.4, { y: 50, opacity: 0 }, { y: 0, opacity: 1, ease: Power4.easeOut });
tl.fromTo('.sub-heading', 0.4, { y: 50, opacity: 0 }, { y: 0, opacity: 1, ease: Power4.easeOut });
tl.fromTo('.video', 0.4, { y: 50, opacity: 0 }, { y: 0, opacity: 1, ease: Power4.easeOut });

Plug type write element and what code it is necessary to apply, here's an example:
$('.slider').slick();
( In your file named anim.js my animation function ( animate() ), I import it into main.js and $(element name).animate(); )
But in the function slider() no name of the item, I asked.

That's the kind of effect you want to achieve. If that don't specify that you understood the question.
April 3rd 20 at 18:40
0 answer

Find more questions by tags JavaScriptjQuery