I'm experimenting with changing the background of my webpage using Angular framework. I want to switch between different CSS files by clicking on buttons within the same page.
CSS1.css
body {
background-image: url("./Images/mg.jpg");
}
CSS2.css
body {
background-image: url("./Images/mg.jpg");
}
I have created two buttons in the HTML file, where clicking on button1 should load CSS1.css and clicking on button2 should load CSS2.css.
I tried to assign an ID to each button and map a script function to them, but encountered a runtime error.
HTML File
<button type="button" id="button1" onclick="myFunction()">background1</button>
<link rel="stylesheet" type="text/CSS" href="CSS1.css" id="theme">
Script file
function myFunction()
{
document.getElementById("button1")= document.getElementById("theme");
}
Can someone please guide me on where I may have gone wrong here? Thanks.