How to use a variable to reference the object?

The essence of the question, I want to create a function that when you press the button to get the attributes of this button, and for him to pay to a particular object.

$('[scroll to]').on('click',function () {
 let parallaxElement = $(this).attr('id');
 let direction = $(this).attr('scroll-to');

Something like that. Do for getting rid of doublea code.
March 23rd 20 at 18:56
1 answer
March 23rd 20 at 18:58

ahah, Yes it is) - Sarai commented on March 23rd 20 at 19:01

Find more questions by tags JavaScript