JSFiddle - React, Tailwind, and code Playground

HTML

<a href="/link.php?destination=1" target="_blank">
    link text
</a>
<a href="/link.php?destination=1" target="_blank">
  <img src="/image.jpg">
  <span>link text</span>
</a>

JavaScript

document.addEventListener('click', function(e) {
  var target = e.target
  
  while (target && target.tagName !== 'A') {
    target = target.parentNode;
    if (!target) { return; }
  }
  
  if (target.href.indexOf("link.php") > -1) {
    alert('it worked');
  }
}, false);