0

I have a div representing a panel that acts as a link. This panel contains a button that triggers some Javascript.

How can I do so that the button does not activates that link ?

<a href="/some/page">
    <div>
        ...
        <button onClick="someFunction()">Click</button>
    </div>
</a>
Bielna
  • 131
  • 4
  • 1
    You can't; it's invalid HTML to nest one interactive element within another. – David Thomas Dec 01 '16 at 21:18
  • I'm by no means a web dev professionals, but one approach that comes to my mind is to remove the button from the panel, make it as it's own element, and use `position: fixed` to overlay it on the panel. Again, not a web dev professional, so take that suggestion with a heavy grain of salt. – tblznbits Dec 01 '16 at 21:20

1 Answers1

0

you can try

<a href="/some/page" onclick="return false;">Click me</a>

this will prevent the default action.

Eli
  • 4,329
  • 6
  • 53
  • 78