I'd like to ask about HTML tag
<a href="www.mysite.com" onClick="javascript.function();">Item</a>
How to make this a tag working with href and onClick? (prefer onClick running first then href)
I'd like to ask about HTML tag
<a href="www.mysite.com" onClick="javascript.function();">Item</a>
How to make this a tag working with href and onClick? (prefer onClick running first then href)
You already have what you need, with a minor syntax change:
The default behavior of the
<a>
tag'sonclick
andhref
properties is to execute theonclick
, then follow thehref
as long as theonclick
doesn't returnfalse
, canceling the event (or the event hasn't been prevented)To achieve this use following html:
Here is working example.
Use
ng-click
in place ofonclick
. and its as simple as that:Use jQuery. You need to capture the
click
event and then go on to the website.