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
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
Share Improve this question asked Dec 10, 2013 at 12:15 user3086778user3086778 331 silver badge3 bronze badges 3- 4 why dont you simply remove the onclick from this tr ? – Sunil Verma Commented Dec 10, 2013 at 12:18
- I'd hoped to make the entire row clickable except the last column and using onclick in <tr> rather than a separate one in each <td> seems a neater solution. – user3086778 Commented Dec 10, 2013 at 12:34
- try using adding onclick="return false" in last td – Sunil Verma Commented Dec 10, 2013 at 12:36
3 Answers
Reset to default 11Here is the code - http://jsbin./iLISUDu/2/
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<table>
<tr onclick='window.location.href="google.";'>
<td>Hello</td>
<td>We are cells</td>
<td onclick='event.stopPropagation();return false;'>Click Me</td>
</tr>
</table>
</body>
</html>
try
<td onclick="(function(e){e.preventDefault();})">A</td>
Click events can be cancelled by returning false from the handler event.