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

227
Views
Change color of a SVG in Favicon

I want to change the color of a SVG that I use as a Favicon in an HTML-Page. I wantto use a button and if you click the button it should change the Favicon.

I already got it to work with normal SVG elements on my page, but I can not a way that work for Favicon.

Has anybody a idea how you can do it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<link id="favicon" rel="icon" href="image-name.svg" type="image/png" sizes="16x16">

create two icons and replace using js function.

<button class="btn2" type="button" onclick="changeFavicon()"> Change Favicon </button>


// Assign a constant variable and get them by the favicon Id
const favicon = document.getElementById("favicon");

// Creating a function for the button
function changeFavicon() {
    favicon.setAttribute("href", "image-name2.svg"); 
}
about 4 years ago · Juan Pablo Isaza Report
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!