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?
<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");
}