The proper way to invoke javascript code when clicking a link would be to add an onclick
handler:
<a href="#" onclick="myFunction()">LinkText</a>
Although an even "more proper" way would be to get it out of the html all together and add the handler with another javascript when the dom is loaded.