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

91
Views
how to reload a specific element with js

I just wat to know how I can reload a specific element or div with javascript code.

div:

<div id="profile_img">
   <figure>
      <img id="holla" src="avatar.gif"/>
   </figure>
</div>

hope you will help . I really need it . Thank you

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can easily set the source of an image in JS:

document.getElementById("holla").src = "avatar.gif";

function refresh() {
document.getElementById("holla").src = "avatar.gif";
}
<div id="profile_img">
   <figure>
      <img id="holla" src="avatar.gif"/>
   </figure>
</div>
<button onclick="refresh();">Refresh Image</button>

about 4 years ago · Juan Pablo Isaza Report

0

If you are trying to reload from server then you can do ajax call and set the response to that div. document.getElementById('holla').innerHTML = this.responseText;

about 4 years ago · Juan Pablo Isaza Report

0

You must have some mechanism to load the image. Ajax call will load the image asynchronously.

// Create an XMLHttpRequest object
const xhttp = new XMLHttpRequest();
// Define a callback function
xhttp.onload = function() {
  //you get response back from server in responseText.
  document.getElementById('holla').innerHTML = this.responseText;
}
// Send a request
xhttp.open("GET", "ajax_info.txt");// path to file
xhttp.send();
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!