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

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