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

191
Views
Change bootstrap icon by using onclick function

I want to change the bootstrap icon bi bi-caret-right-fill to bi bi-caret-down-fill.

<i onclick="myFunction(this)" class="bi bi-caret-right-fill"></i>
function myFunction(x) {
   x.classList.toggle("bi bi-arrow-down-circle");
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In your case you need to do like this

Hope this will help you

function myFunction(x) {
   x.classList.toggle("bi-caret-right-fill"); 
   x.classList.toggle("bi-arrow-down-circle"); 
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<i onclick="myFunction(this)" class="bi bi-caret-right-fill"></i>

about 4 years ago · Juan Pablo Isaza Report

0

Try this:

<i onclick="myFunction(this)" class="bi bi-caret-right-fill"></i>
function myFunction(x) {
  if (x.classList.contains("bi-caret-right-fill")) {
    x.classList.remove("bi-caret-right-fill");
    x.classList.add("bi-arrow-down-circle");
  } else if (x.classList.contains("bi-arrow-down-circle")) {
    x.classList.add("bi-caret-right-fill");
    x.classList.remove("bi-arrow-down-circle");
  }
}
about 4 years ago · Juan Pablo Isaza 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!