javascript - HTML tag <a> want to add both href and onclick working -


i'd ask html tag

<a href="www.mysite.com" onclick="javascript.function();">item</a> 

how make a tag working href , onclick? (prefer onclick running first href)

you have need, minor 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 want allow `href` property follow through or not     } </script> 

the default behavior of <a> tag's onclick , href properties execute onclick, follow href long onclick doesn't return false, canceling event (or event hasn't been prevented)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -