0

I am facing a issue in a <table>

I have a table row which having a Redirect URL and only one table data <td> having different functionality

<table>
    <thead>
        <th></th>
        <th>Name</th>
        <th>ID</th>
        <th>Active</th>
    </thead>
    <tbody>
        <tr type="button" onclick="window.location.href = '/xxx/bbb/001';">
            <td id="dtr-control"></td>
            <td>XXXXXXXXXX</td>
            <td>001</td>
            <td>True</td>
        </tr>
    </tbody>
</table>

in the above html, <tr> will act like a link and the first <td> having its own functionality like click on the first it will list the other options/controls of the table, it is working fine but also it is redirecting to the page which is defined in the <tr>.

If I click first <tr> it should list the options and if I click rest of the row it should redirect me to other page.

How to stop only the parent functionality?

Thanks in Advance.

Gokul Kannan
  • 53
  • 2
  • 14
  • 2
    I understand that this is your requirement, but for the sake of following good practices, you should come up with a better html/design. – Sang Suantak Sep 28 '21 at 10:40
  • You'll probably need some JS to do this, like using [`Event.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault), but I agree with @Sang here. – DavidG Sep 28 '21 at 10:43
  • Does this answer your question? [How to stop event propagation with inline onclick attribute?](https://stackoverflow.com/questions/387736/how-to-stop-event-propagation-with-inline-onclick-attribute) – freedomn-m Sep 28 '21 at 10:47
  • `