-1

I have a circle created with border-radius. If I click on the cut-off area, the event still fires. How do I prevent this natively? Or is the only solution to check it in JS?

SherylHohman
  • 14,460
  • 16
  • 79
  • 88

1 Answers1

2

I tried to recreate your case and it works just fine. Both with div+border-radius approach and svg

document.getElementById("circle1").onclick = function() {
  alert("svg clicked")
}

document.getElementById("circle2").onclick = function() {
  alert("div clicked")
}
.circle {
  width: 100px;
  height: 100px;
  
  border-radius: 50%;
  background-color: tomato;
}
<svg height="100" width="100">
  <circle cx="50" cy="50" r="50"  fill="red" id="circle1"/>
</svg>

<div class="circle" id="circle2"></div>
flppv
  • 3,679
  • 3
  • 31
  • 48