Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

How to have JS take care of multiple events for a div

$
0
0

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.


Viewing all articles
Browse latest Browse all 67411

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>