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

84
Views
How to change icon on AJAX results search by id

I have multiple icons, I want to change my certain icon to another icon based on the ajax result. For example, when the res = true, my bookmark icon needs to change to fa fa-address-card icon. Now the code is when the res = true, both icon will change. Does anyone know how to solve it? Thanks in advance.

<i id="bookmark" class="fa fa-bookmark"></i>
<i id="database" class="fa fa-database"></i>


$('i').removeClass('fa-bookmark');
$('i').addClass('fa fa-address-card');
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

your second jquery line is causing the problem

in both jquery selectors you are selecting all i tags in your html,,

first one isn't causing any trouble because it HAS 'fa-bookmark' and others don't so it will remove bookmark icon class

but in the second one you are applying fa-address-card to all i elements and that's why other icons are getting changed

$('#bookmark').removeClass('fa-bookmark').addClass('fa-address-card');

this is a better approach and will solve your problem

over 4 years ago · Santiago Trujillo 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!