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

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