Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel onclick event for one column in table

I've done some digging and been unable to find a solution to this little problem. I have a table where I've made each row clickable using:

<tr class="clickable" onclick="window.document.location='$link';">

I'd like to make this work for all but the last column in the table but all the solutions I've found so far involve jQuery. Is there a way of "cancelling" the row onclick event for one column?

TIA

like image 340
user3086778 Avatar asked Nov 23 '25 11:11

user3086778


2 Answers

Here is the code - http://jsbin.com/iLISUDu/2/

  <!DOCTYPE html>
  <html>
  <head>
  <meta charset=utf-8 />
  <title>JS Bin</title>
  </head>
  <body>
    <table>
      <tr onclick='window.location.href="google.com";'>
        <td>Hello</td>
        <td>We are cells</td>
        <td onclick='event.stopPropagation();return false;'>Click Me</td>
      </tr>
    </table>
  </body>
  </html>
like image 143
Rohit Agrawal Avatar answered Nov 25 '25 02:11

Rohit Agrawal


try

<td onclick="(function(e){e.preventDefault();})">A</td>

like image 27
The Mighty Programmer Avatar answered Nov 25 '25 02:11

The Mighty Programmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!