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

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

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 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!