Custom event not getting triggered

Does it make any difference for custom event to be called if element target is blank.

Also the anchor tag opens in another in new tab. Does it mean control gets transferred before the custom event trigger. Can this be rectified using script placement changes or any other way, as the custom attribute works fine.


a href=“URL*” id=“id” target="_blank">**</a

Script tried and failed:

window.addEventListener(‘DOMContentLoaded’, (event) => {

document.getElementById(‘id’).addEventListener(‘click’,function (e) {