javascript - Jquery Onclick priority vs Href -
i've small problem set priority on href vs onclick:
$("#table_head tr").click(function (e) { /* function */ }); but if use "href" :
<table id="table_head"> <tr> <td><a href="http://stackoverflow.com">my link</a></td> </tr> </table> how can priorise href vs onclick please?
assuming mean you're trying execute code before page redirected, need stop normal link behaviour using preventdefault(), process logic, manually redirect page using window.location.assign(). try this:
$("#table_head tr").click(function (e) { e.preventdefault(); /* function */ if (e.target.tagname == 'a') window.location.assign(e.target.href); });
Comments
Post a Comment