HTML <a> tag wants to add both href and onclick working
I would like to ask about the HTML tag
<a href="www.mysite.com" onClick="javascript.function();">Item</a> How to make this a tag work with href and onClick ? (first select onClick then href)
+81
user1589113 Feb 14 '13 at 3:56
source share2 answers
You already have what you need, with a slight syntax change:
<a href="www.mysite.com" onclick="return theFunction();">Item</a> <script type="text/javascript"> function theFunction () { // return true or false, depending on whether you want to allow the `href` property to follow through or not } </script> By default, the <a> onclick and href tag properties should execute onclick by default and then follow href until onclick returns false , canceling the event (or the event has not been prevented)
+153
Ian Feb 14 '13 at 4:01 2013-02-14 04:01
source shareUse [jQuery] [1]. You need to capture the click event and then go to the website.
+9
Sudipta Chatterjee Feb 14 '13 at 4:01 2013-02-14 04:01
source share