Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Cambiar icono después de hacer clic en él y también cuando hacemos clic en otro botón en html

Estoy buscando cambiar el ícono cuando hago clic en él y también cuando presiono otro botón.

Situación actual: puedo cambiar el ícono usando .toggle pero no puedo encontrar la manera de cambiarlo cuando presiono otro botón.

Código:

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 answers
Answer question

0

Puede encontrar su elemento utilizando el método getElementById de Javascript.

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

Luego puede alternar su classList como lo hizo con otro botón antes.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!