anchor element onclick not working

Solutions on MaxInterview for anchor element onclick not working by the best coders in the world

showing results for - "anchor element onclick not working"
Owen
16 Aug 2016
1//Onclick event of anchor tag won't work if href is set.
2//Workaround: make href call a function that does onclick and then redirects page to link address
3//NOT GOOD: <a href="/info" onclick="doSomething();" >Link </a>
4//BETTER: <a href="javascript:onLinkClick();" >Link </a>
5function onLinkClick()
6{
7  doSomething();
8  window.location.href = "/info";
9}