Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda