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
Post a Comment