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

131
Visualizações
Is there a way to change a p element's innerHTML based on an img src that changes in a slideshow?

I currently have some variables that are strings which should go into my p tag's innerHTML depending on the img src thats currently displayed from a slideshow array. onload it should display the variable product1info (which is just a string) and if I hit next or previous in the slideshow the img source changes. Based on that img source the product1info should change to the string that matches the img src. i.e. product1info, product2info, product3info etc.

This is part of my code right now and I'm not sure what this if statement should look like but i think this is where it needs to be fixed:

var imgsource = document.getElementById('slide').src; //this is the img slideshow where I get src from

var infosub = document.getElementById('info'); //this is the paragraph where I am trying to write the productinfo variables

function info(){
    if (imgsource == 'productt1.jpg'){
        infosub.innerHTML = product1info;
    }
}
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