JSFiddle - React, Tailwind, and code Playground

by Bhavin Surela

JavaScript

// Get all anchor elements
const anchors = document.getElementsByTagName('a');

// Create an array to store the emails
var emails = "";

// Loop through each anchor element
for (let i = 0; i < anchors.length; i++) {
  const anchor = anchors[i];
  const href = anchor.getAttribute('href');

  // Check if the href attribute starts with "mailto:"
  if (href && href.startsWith('mailto:')) {
    // Extract the email address from the href attribute
    const email = href.replace('mailto:', '');

    // Add the email
    emails = emails+"\n"+email;
  }
}

// Log the emails array
console.log(emails);