JSFiddle - React, Tailwind, and code Playground

by Jehuty

HTML

<a href="https://webtrh.cz" class="js-emaillink" data-email="test@test.com">Email and Link</a>

Babel + JSX

const emailLinks = document.querySelectorAll('.js-emaillink');
Array.prototype.forEach.call(emailLinks, link => link.addEventListener('click', e => {
  const to = e.target.getAttribute('data-mail');
	const iframe = document.createElement('iframe');
  const body = document.querySelector('body');
  iframe.setAttribute('src', `mailto:${to}`);
  iframe.setAttribute('onload', 'this.remove()');
  iframe.style.display = 'none';
  body.appendChild(iframe);
}))