I'm drawing a blank on how to handle events within Javascript, and want to avoid using a modular function that has the "onclick" within the html tag. Basically, I want to write a function that will scroll to the section of the page containing that element on click, but I'm drawing a blank on how to do that.
I have a modular function like this:
var elmnt = $("#links").on("click", function() {
elmnt.scrollIntoView;
console.log;
});
Now, I pass the argument on the a href tag, but how do I have JS look for these events and scroll to them? Do I write a function for each link clicked? Is there a better way to do that? Thank you in advance.