JSFiddle - React, Tailwind, and code Playground

HTML

<div opep="1" opep-popup-url="//new-link">
  <a href="//old-link">click me</a>
  <div opep="1" opep-popup-url="//new-link">
  <a href="//old-link">click me</a>
  </div>
</div>

JavaScript

jQuery(document).ready(function( $ ) {

	function opepSetLinksPopups() {

    $(document).find('[opep="1"]').each(function() {
    
      $(this).find('a:not([no-opep], [post-url])').each(function () {
      		const postUrl = $(this).attr('href');
          const popupUrl = $(this).closest('[opep="1"]').attr('opep-popup-url');
          $(this).attr('post-url', postUrl);
          $(this).prop('href', popupUrl);
          
      });
    });
  }
  
  opepSetLinksPopups();
    
});