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> 
2
  • 1
    You can't; it's invalid HTML to nest one interactive element within another. Commented Dec 1, 2016 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. Commented Dec 1, 2016 at 21:20

1 Answer 1

0

you can try

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

this will prevent the default action.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.