Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

89
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda