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

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 -

How to provide Authorization & Authentication using Asp.net, C#? -