Ideally, you will not use either. Ideally, your link is a normal hyperlink with a href value referring to a fragment ( #foo ) or URL. Ideally, the link would just work - without Javascript too.
Then you used unobtrusive Javascript , which, if necessary, is bound to links or other DOM elements, and only if Javascript is available:
<a href="/some/action" id="foobar">Do some action!</a> <script type="text/javascript"> document.getElementById('foobar').addEventListener('click', function () { </script>
source share