-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
  • 16,580
  • 17
  • 88
  • 94
Dmitry Sharshakov
  • 678
  • 1
  • 6
  • 7

1 Answers1

3

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
  • 4,111
  • 5
  • 35
  • 54