Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

anchor element onclick not working

//Onclick event of anchor tag won't work if href is set.
//Workaround: make href call a function that does onclick and then redirects page to link address
//NOT GOOD: <a href="/info" onclick="doSomething();" >Link </a>
//BETTER: <a href="javascript:onLinkClick();" >Link </a>
function onLinkClick()
{
  doSomething();
  window.location.href = "/info";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #anchor #element #onclick #working
ADD COMMENT
Topic
Name
8+8 =