I have a link and inside this link an icon, I'd like to be able to click on the icon without triggering the link.
For example:
This whole block is a link and I have the green square inside it. What I want to do is to make the green square ignore the parent link. Would that be possible?
Just to be clear, I don't want to disable the link, I want it working in the pink area and ignored only by the green square.
So, some people suggested this post, but it doesn't answer my question: How to disable HTML links
Here is an example of my code followed by a codepen with it.
HTML:
<a href="https://www.facebook.com/">
  <div  class="container">
       <div onClick="dontCallLink()" class="subDiv"></div>
  </div>
</a>
JS:
function dontCallLink(event) {
  document.getElementsByClassName('subDiv')[0].style.backgroundColor = "red"
}
CSS:
.container {
  height: 250px;
  width: 200px;
  background-color: pink;
}
.subDiv {
  width: 30px;
  height: 30px;
  background-color: green;
  margin-left: 160px;
  margin-top: 200px;
  position: absolute;
  cursor: default;
}

