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

262
Vistas
Change Icon after clicking it and also when we click on other button in html

I am looking to change the Icon when i click on it and also when i press another button.

Current situation: i m able to change the icon using .toggle but unable to figure out way to change it when i press another button.

Code:

HTML:

<a link=# onClick="someOtherFunction()">Change Icon by Click</a>
<br>
<button class="mail_btn click" onclick= "someOtherFunction(); changeIcon();">
            <i id ='mailBTN' class="fa-solid fa-envelope envelope" onclick="changeIcon(this)"></i>

            <!-- this is the icon i want 
                  <i class="fa-solid fa-envelope-open-text">
              </i> -->

</button>

JavaScript:

function changeIcon(icon){
    icon.classList.toggle('fa-envelope-open-text');
} 


about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You can find your element by using Javascript getElementById method.

function anotherButtonClick() {
  var el = document.getElementById("mailBTN");
  el.classList.toggle('fa-envelope-open-text');
}

Then you can toggle your classList as you did for other button before.

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