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

210
Vistas
On click reveal an email address

I have the following code that allows me to reveal an email address on click. The problem is that I want the Show E-mail to disappear when I click on it and just return the email address.

Can you please help?

Thanks!

function SEmail() {
  var x = document.getElementById('email');
  if (x.style.display == 'none') {
    x.style.display = 'block';
  }
}
<p class="email">
  <?php _e('E-mail:', 'theme') ?>
  <span onclick="SEmail()"><a href="#">Show E-mail</a></span>
  <span id="email" style="display:none"><a href="mailto:<?php echo contact_email(); ?>">Email link</a></span>
</p>

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Solved it with the below, by giving the text id to the placeholder text:

<script>
function SEmail() {
    var x = document.getElementById('email');
        x.style.display = 'block';
    var y = document.getElementById('text');
        y.style.display = 'none';
}
</script>
<p class="email">
  <?php _e('E-mail:', 'theme') ?>
  <span id="text" onclick="SEmail()"><a href="#">Show E-mail</a></span>
  <span id="email" style="display:none"><a href="mailto:<?php echo contact_email(); ?>">Email link</a></span>
</p>

Thanks for help @ChrisG and @isherwood

about 4 years ago · Juan Pablo Isaza Denunciar

0

Just add another function to hide it onclick

try this

HTML:

<p class="email">
  <?php _e('E-mail:', 'theme') ?>
  <span onclick="SEmail()"><a href="#">Show E-mail</a></span>
  <span onclick="HideEmail()" id="email" style="display:none"><a href="mailto:<?php echo contact_email(); ?>">Email link</a></span>
</p>

JavaScript

function SEmail() {
  var x = document.getElementById('email');
  if (x.style.display == 'none') {
    x.style.display = 'block';
  } else  {
    x.style.display = 'none';
  }
}

function HideEmail() {
  var x = document.getElementById('email');
  x.style.display = 'none';
  
}
about 4 years ago · Juan Pablo Isaza 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