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

89
Visualizações
Changing only the url path catalogue with javascript

So im having this problem and not sure how to tackle it

I have <img src="~/images/arrow-repeat.svg">

but i want to change the src to <img src="~/images**/darkmode/**arrow-repeat.svg" depending on the conditions.

I only want to target the path and not the image itself Just the <img src="**~/images/**arrow-repeat.svg" part and i want to add /darkmode/ to the src source without touching the "arrow-repeat.svg"

How can i achive this in javascritp?

I have tried to target the image by adding a ID to it and then doing

document.getElementById('icon').src = "\~/images/";

if (darkSwitch.checked) {
    document.getElementById('icon').src = "~/images/darkmode/";
} else {
    document.body.classList.remove('darkmode');
}

But it just replaces the whole src, i want to just target the path and not the image

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