Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!