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

191
Visualizações
Onclick to change image

I have two DIVs on the left are thumbnail images and on the right I have one image. I am trying to click an image on the left side and have it replace the image on the right side. Currently when I select a thumbnail image I get the swirly indicator that the function has been called but the image isn't updated. Can this be completed with normal javascript or should JQuery be used.

<script type="text/javascript">
        
    //  This function will display photos selected by user
     function showDirectory(){
         var myFiles = document.getElementById("files");
         for(var i=0;i<=myFiles.files.length; i++){
            var x = myFiles.files[i].name;
            document.getElementById("demo1").innerHTML += "<img onclick='switchImage("+x+")' src='"+x+"' style='width:40px; height:40px; margin:5px'>"
         }
     }
            
    function switchImage(e){
       document.getElementById("rightside").src=e;
    }
</script>
Show files in the Directory

    <div class="item" style="width: 70%; background-color: bisque; padding: 5px;">
       <img id="rightside" src="RightSide.jpg" alt="Picture of " style="height: 720px; width:720px">
        <p  style="color: #000; text-align: right;">Slide1.jpg</p>
    </div>
</div>
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