How to call JavaScript function on link click instead of href in HTML?

Spread the love

To call JavaScript function on link click instead of href in HTML, we set the onclick attribute to call a JavaScript function.

For instance, we write

<a href="javascript:void(0);" onclick="showOld(2367, 146986,2);"> </a>

to set the href attribute to javascript:void(0); to stop navigation.

And we set the onclick attribute to call the showOld function.

Leave a Reply

Your email address will not be published.