Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
add mailto: before every email

hey so I have a html table with a bunch of people and email addresses. I want to add mailto: before every email. is there anyway to do this using javascript, or preferably a find/replace function in vscode?

  <tr>
    <td>Mrs. john doe</td>
    <td></td>
    <td>first.last4@example.com</td>
    <td>Principal</td>
</tr>
<tr>
    <td>Mr. jerremy fields</td>
    <td></td>
    <td>first.last@example.com</td>
    <td>Deputy</td>
</tr>
<tr>
    <td>Mrs. rebecca statin</td>
    <td></td>
    <td>first.last@example.com</td>
    <td>Deputy</td>
</tr>

ive tried using a vscode find/replace like this:

Find: .+?..+?@example.com Replace: <td>mailto:.+?..+?@example.com

The find works, yet when I try and replace the actual '.?' is being replaced instead of the previous wildcard expression

thanks in advance

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You can use the code below. Remember - for mailto: to work, it needs to be in an <a>

Adding a CSS class to the <td> will make the code easier to maintain because if the table structure changes, the email addresses can still be accessed.

<td class="email">email@example.com</td>

const emails = document.querySelectorAll(".email");

const emails = document.querySelectorAll("tr td:nth-of-type(3)");
emails.forEach(e => e.innerHTML = '<a href="mailto:' + e.textContent + '">' + e.textContent + '</a>');
<table>
<tr>
  <td>Mrs. john doe</td>
  <td></td>
  <td>first.last4@example.com</td>
  <td>Principal</td>
</tr>
<tr>
  <td>Mr. jerremy fields</td>
  <td></td>
  <td>first.last@example.com</td>
  <td>Deputy</td>
</tr>
<tr>
  <td>Mrs. rebecca statin</td>
  <td></td>
  <td>first.last@example.com</td>
  <td>Deputy</td>
</tr>
</table>

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda