Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda