Triggering multiple mailto links with jquery

by gaboom

HTML

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<a id="send" href="#">CLICK TO SEND</a>
<div id="links" class="hidden">
  <a href="mailto:[email protected]">John</a>
  <a href="mailto:[email protected]">Sarah</a>
  <a href="mailto:[email protected]">John</a>
  <a href="mailto:[email protected]">Sarah</a>
  <a href="mailto:[email protected]">John</a>
  <a href="mailto:[email protected]">Sarah</a>
</div>

CSS

.hidden {
  display: none;
}

JavaScript

$("#send").on("click", function(event) {
  event.preventDefault();
  $("#iframes").empty();
  $("#links a").each(function() {
    setTimeout($.proxy(function() {
      var popup = window.open($(this).attr("href"))
      setTimeout($.proxy(function() {
        this.close();
      }, popup), 100);
    }, this), 100)
  })
})