JSFiddle - React, Tailwind, and code Playground

by wwt

HTML

<p><a href="//example.org">example</a></p>
<p><a href="//example.org">example</a></p>
<p><a href="//example.org">example</a></p>
<p><a href="//example.org">example</a></p>
<p><a href="//example.org">example</a></p>

JavaScript

/*$('a').each(function(){
	$(this)
      .data('href', $(this).attr('href'))
      .attr('href','//:')
    	.on('click', function(){
    		location.href = $(this).data('href');
  		});
});
*/
window.onload = function(){
    var links = document.querySelectorAll('a');
    for(var i = 0; i < links.length; i++){
    
      var a = links[i];
      
      a.setAttribute('data-href', a.getAttribute('href'));
      a.setAttribute('href','//:');
      a.onclick = function(){
        location.href = this.getAttribute('data-href');
        return false;
      }
    }
};