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

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

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 Relatório

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 Relatório

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 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