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

80
Visualizações
Image not Updating using DOM manipulation

I am trying to toggle between 2 images based on a condition. I am thinking to change the src of img tag. I am able to change the src but on the webpage the image is not getting updated.

can someone point out where or what should be used or updated.

Here is my JS code ->

success: function(data){
        if(data.status == 200){
          if(data.message == "Liked"){
            document.getElementById("like_image_state_change").src="{% static 'FrontEnd1/Static_Images/CovrPage_Like_R.png' %}";

          } 
          else if(data.message == 'Like Removed'){
            document.getElementById("like_image_state_change").src="{% static 'FrontEnd1/Static_Images/CovrPage_Like_W.png' %}";
            console.log(document.getElementById("like_image_state_change"));
          }
        }
        else{
          console.log('wrong');
        }
      }
    });

Here when I console the document.getElementById in 'like Removed' I could see the updated src for the Image but the Image is still the same on the webpage.

PS -> The backend I am using is DJango. (if it matters)

about 4 years ago · Juan Pablo Isaza
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