I have an <a>
element that has several children inside. Requirements changed and now <a>
might or might not have a link on it. The easiest way to change it would be to disable click events for <a>
and keep it for children (they have some functionality that depends on pointer events).
When I apply pointer-events: none
to the <a>
parent, everything is fine – the link doesn’t work. When I then apply pointer-events: auto
to <a>
children, the link becomes active again.
The generated html is like so:
<a href class='no-pointer-events'>
<figure class='pointer-events-auto'></figure>
</a>
How can I solve this?
2
Answers
The following worked almost as intended:
<a href={tab.url ? tab.url : "javascript:void(0)"} >
. The only problem is it shows'javascript:void(0)'
as the link, but otherwise works ok and the link is unclickable.From: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
Therefore if you set any child with pointer events, it will bubble up to the parent.