I’m curious whats the best way to call a JS function with a href link in HTML. I don’t use a library and i see alot of mention about jquery using event handlers …
But if im not using a library can it still be done or will i have to use an on click type call ?
You can use event handlers with plain javascript. No framework is required. Here’s a cross browser function I use:
And, an example of using it would be like this:
HTML:
Javascript:
If you don’t want the default click of a link to happen, then you need to prevent the default behavior from the event handler like this: